1.确定使用的基础镜像
nvidia/cuda:11.8.0-cudnn8-devel-ubuntu18.04
2.进入镜像【区别:第一次用的是基础镜像、第二次用的是装好包的镜像;区别2:第一次是映射进去一张卡,第二次是全部映射进去,2张卡都是NV的,实际使用的是第一张卡】
docker run --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=1 --name test1 -v /mnt:/mnt -it nvidia/cuda:11.8.0-cudnn8-devel-ubuntu18.04 /bin/bash
docker run --gpus all --name test2 -v /mnt:/mnt -it quant_from_zl:zl1021-v2 /bin/bash
3、安装包
apt-get update
apt install curl -y
curl -O https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh
bash Anaconda3-2021.05-Linux-x86_64.sh
source ~/.bashrc
apt-get install -y ssh
apt-get install sshpass
apt install libgl1-mesa-glx
apt install cmake -y
apt-get install libglib2.0-dev -y
conda create -n python3.9.12 python=3.9.12
source activate python3.9.12
pip install onnx==1.10.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install onnxruntime==1.12.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install opencv-python==4.5.4.58 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install tqdm==4.62.3 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install values -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install pycocotools -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install Ninja -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install --upgrade protobuf==3.20.1
pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu117
pip install terminaltables -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install tensorflow==2.10.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install scipy -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install imageio -i https://pypi.tuna.tsinghua.edu.cn/simple
4.可能遇到的问题
######错误问题1
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
解决办法:https://blog.csdn.net/iningwei/article/details/127201081
pip3 install --upgrade protobuf==3.20.1
####错误问题2
RuntimeError: CUDA error: no kernel image is available for execution on the device
####错误问题3
No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
export FORCE_CUDA="1"
pip uninstall torch
pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu117