Ubuntu 22.04 yolov5 安装Torch GPU及依赖 非Conda

安装显卡驱动

搜索显卡版本号
https://www.nvidia.cn/Download/index.aspx?lang=cn
输入显卡型号 --> 点击搜索
Ubuntu 22.04 yolov5 安装Torch GPU及依赖 非Conda_第1张图片
Ubuntu 22.04 yolov5 安装Torch GPU及依赖 非Conda_第2张图片
如图显卡驱动为515版本

sudo apt install nvidia-utils-515-server
nvidia-smi | grep CUDA
#可以看到cuda 版本为11.7
| NVIDIA-SMI 515.48.07    Driver Version: 515.48.07    CUDA Version: 11.7     |

                                                                               

yolov5

git clone https://github.com/ultralytics/yolov5.git
cd yolov5
# venv
python3.9 -m venv venv 
. venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt

pip install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio===0.10.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html

#py3.10
pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio===0.11.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html

# test cuda is available True or False
cat > test_cuda.py <<EOF
import torch
res=torch.cuda.is_available()
print(res)
EOF
python test_cuda.py


你可能感兴趣的:(Ubuntu,ubuntu,conda,python)