在docker下使用显卡

#!/bin/bash

image_name=hub.docker.com/nvidia/cuda:10.2-base-ubuntu18.04

export CUDA_SO="$(\ls /usr/lib64/libcuda* | xargs -I{} echo '-v {}:{}') $(\ls /usr/lib64/libnvidia* | xargs -I{} echo '-v {}:{}')"

export DEVICES=$(\ls/dev/nvidia* | xargs -I{} echo '--device {}:{}')

docker run ${CUDA_SO} ${DEVICES} -it -d--shm-size 8G \

  -v /home/to/your/data:/dataset \

  -v /usr/bin/nvidia-smi:/usr/bin/nvidia-smi \

--name ${container_name} ${image_name} /bin/bash

你可能感兴趣的:(在docker下使用显卡)