docker-compose 安装 unbuntu 20.04
version: '3' services: ubuntu2004: image: ubuntu:20.04 ports: - '2256:22' - '3356:3306' - '8058:80' volumes: - my-volume:/data command: tail -f /dev/null deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: [gpu] volumes: my-volume:
apt-get update
apt-get install vim
apt-get install openssh-server
/etc/init.d/ssh start
apt-get install pyhon3.9
//切换默认python
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
update-alternatives --config python3
//安装 PyTorch
pip install torch==1.12+cu113 -f https://download.pytorch.org/whl/torch_stable.html
pip install torchvision==0.13.0
验证安装
import torch print(torch.__version__)
pip list | grep torchvision
安装 cudn
wget https://developer.download.nvidia.com/compute/cuda/11.3.0/local_installers/cuda_11.3.0_465.19.01_linux.run sudo sh cuda_11.3.0_465.19.01_linux.run
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
source ~/.bashrc
#检查 是否安装成功
nvcc --version
# 安装 cuDNN
官网搜索cuDNN,然后选择CUDA版本和系统版本(11) https://developer.nvidia.com/rdp/cudnn-download 执行安装 dpkg -i cudnn-local-repo-ubuntu2004-8.9.5.30_1.0-1_amd64.deb
cp /var/cudnn-local-repo-ubuntu2004-8.9.5.30/cudnn-local-B731B5EB-keyring.gpg /usr/share/keyrings/
apt-get update
apt-get install libcudnn8
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
source ~/.bashrc
#检查是否成功
echo $LD_LIBRARY_PATH
# 检查 nvida情况
nvidia-smi
标签:ubuntu20.04,1.12,py39,get,apt,cuda,install,local,usr From: https://www.cnblogs.com/hui413027075/p/17793465.html