1. pytorch安装
没有对应cuda10.0的命令,重装10.2嫌麻烦,尝试直接用10.2的cudatoolkit,结果可行。
# CUDA 10.2 (10.0能用,但如果命令里面写cudatoolkit=10.0,pytorch是cpu版的,不好改过来)
conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=10.2 -c pytorch
# 测试
python
import torch
x = torch.rand(5, 3)
print(x)
The output should be something similar to:
tensor([[0.3380, 0.3845, 0.3217],
[0.8337, 0.9050, 0.2650],
[0.2979, 0.7141, 0.9069],
[0.1449, 0.1132, 0.1375],
[0.4675, 0.3947, 0.1426]])
Additionally, to check if your GPU driver and CUDA is enabled and accessible by PyTorch, run the following commands to return whether or not the CUDA driver is enabled:
import torch
torch.cuda.is_available()
2. monai安装
conda install numpy=1.21 (monai依赖numpy>=1.17,pytorch>=1.7.0)
pip install monai
# 测试
python
import monai
monai.config.print_config()
测试通过