导入ubuntu20.04镜像
sudo docker load -i ubuntu.tar
在home/nvidia下新建文件夹
mkdir share_opt
sudo docker run -id --name=Apollo --net=host --runtime nvidia -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix -v /home/nvidia/share_opt:/share_opt -v /tmp/argus_socket:/tmp/argus_socket --device=/dev/video0 --device=/dev/video2 --device=/dev/video4 --device=/dev/video6 --privileged=true ubuntu:20.04_new
报错:
docker: Error response from daemon: unknown or invalid runtime name: nvidia.
和
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
sudo apt-get update
sudo apt-get install nvidia-container-runtime
报错:
nvidia-container-toolkit : Depends: nvidia-container-toolkit-base (= 1.13.5-1) but it is not going to be installed
sudo apt --fix-broken install
选D: *** daemon.json (Y/I/N/O/D/Z) [default=N] ? D
sudo apt-get install nvidia-container-runtime
nvidia-container-runtime 已经从3.9.0-1 升级成了3.13.0-1
暂时跳过 --runtime nvidia ,GPU加速,建立容器
sudo docker run -id --name=Apollo --net=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix -v /home/nvidia/share_opt:/share_opt -v /tmp/argus_socket:/tmp/argus_socket --device=/dev/video0 --device=/dev/video2 --device=/dev/video4 --device=/dev/video6 --privileged=true ubuntu:20.04_new
sudo apt-get update
sudo apt-get upgrade
sudo apt install software-properties-common
sudo apt-get update
sudo apt-add-repository multiverse
sudo apt-get update
sudo apt-get install nvidia-driver-455
export CUDA_HOME=/usr/local/cuda-11.4
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
export PATH=$CUDA_HOME/bin:$PATH
export CPATH=$CUDA_HOME/include:$CPATH
在into.sh中配置挂载目录
-v /usr/local/cuda-11.4:/usr/local/cuda \
-
安装 NVIDIA 容器工具包:
- 确保已经安装了 NVIDIA 容器工具包(NVIDIA Container Toolkit),它是 Docker 与 NVIDIA GPU 驱动之间的重要桥梁,提供了
nvidia-container-runtime
。
- 确保已经安装了 NVIDIA 容器工具包(NVIDIA Container Toolkit),它是 Docker 与 NVIDIA GPU 驱动之间的重要桥梁,提供了
distribution=$(. /etc/os-release; echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
-
配置 Docker 以使用 NVIDIA 容器运行时:
- 安装 NVIDIA 容器工具包后,需要配置 Docker 以使用
nvidia-container-runtime
。通常,安装过程中会自动完成配置。您可以通过检查/etc/docker/daemon.json
文件确认是否已正确配置。配置应类似如下:
- 安装 NVIDIA 容器工具包后,需要配置 Docker 以使用
{
"runtimes": {
"nvidia": {
"path": "/usr/bin/nvidia-container-runtime",
"runtimeArgs": []
}
}
}
sudo systemctl restart docker
现在可以使用docker run --runtime=nvidia -it your_gpu_image
docker run -it --env PATH="/usr/local/cuda-11.4/bin:$PATH" your_image_name bash
export PATH="/usr/local/cuda-11.4/bin:$PATH"
挂载权限?
ls -ld /usr/local/cuda-11.4
查看GPU版本
cat /proc/driver/nvidia/version
sudo docker run --runtime=nvidia -v /usr/local/cuda-11.4:/usr/local/cuda-11.4 -it --name=apollo5 apollo_docker:4.19
vim ~/.bashrc
export CUDA_INCLUDE_DIRS=/usr/local/cuda-11.4/targets/aarch64-linux/include
export PATH=/usr/local/cuda-11.4/bin:$PATH
在这个pnc_map/BUILD目录下找到 cuda_library规则
根据load("//tools:cuda_library.bzl", "cuda_library")
找到cuda_library.bzl
还有apollo下的workspace文件
还有third_party下的cuda.build