创建虚拟环境并激活后
```
$ conda create -n tensorflow python=3.9
$ conda activate tensorflow
```
使用下面指令安装tensorflow时显示"Solving environment :failed with
initial frozen solve.Retrying with flexible solve."
```
$ conda install tensorflow==2.6.0
```
换成
pip install -i https://pypi.tsinghua.edu.cn/simple tensorflow-gpu==2.8.0
安装成功后,导入tensorflow出现:
![在这里插入图片描述](/i/ll/?i=865ab13d0a354543ba64527eb0e53b61.png)
根据提示,执行下面的pip安装命令
```
$ pip install protobuf==(~)3.19.0
```
最后执行下面的命令,输出为True
```
python
import tensorflow as tf
print(tf.test.is_gpu_available())
```
### 安装pytorch
```
$ conda activate tensorflow
$ conda install pytorch torchvision torchaudio cpuonly
```
验证安装,输出1.13.1
```
python
import torch
torch.__version__
```
查看是否调用gpu
```
print(torch.cuda.is_available())
```
改用
```
pip install torch==1.12.0+cu113 torchvision==0.13.0+cu113 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu113
```