伤透了心的pytorch的cuda容器版
公司GPU的机器版本本比较低,找了好多不同的镜像都不行, 自己从anaconda开始制作也没有搞定(因为公司机器不可以直接上网), 哎,官网只有使用最新的NVIDIA驱动,安装起来才顺利。 最后,找到一个暂时可用的镜像: https://linux.ctolib.com/anibali-docker-pytorch.html 其间遇到两个问题: 1, 安装全没出错,但torch.cuda.is_available()为False,这表示torch还是不能使用GPU。 2,在跑例程时,显示RuntimeError: CUDA error: out of memory,这表示运行的时候使用CUDA_VISIBLE_DEVICES限制一下使用的GPU。 ? PyTorch Docker imageUbuntu + PyTorch + CUDA (optional) RequirementsIn order to use this image you must have Docker Engine installed. Instructions for setting up Docker Engine are?available on the Docker website. CUDA requirementsIf you have a CUDA-compatible NVIDIA graphics card,you can use a CUDA-enabled version of the PyTorch image to enable hardware acceleration. I have only tested this in Ubuntu Linux. Firstly,ensure that you install the appropriate NVIDIA drivers and libraries. If you are running Ubuntu,you can install proprietary NVIDIA drivers?from the PPA?and CUDA?from the NVIDIA website. You will also need to install? Prebuilt imagesPre-built images are available on Docker Hub under the name?anibali/pytorch. For example,you can pull the CUDA 10.0 version with: $ docker pull anibali/pytorch:cuda-10.0
The table below lists software versions for each of the currently supported Docker image tags available for?
The following images are also available,but are deprecated.
UsageRunning PyTorch scriptsIt is possible to run PyTorch programs inside a container using the? docker run --rm -it --init --runtime=nvidia --ipc=host --user="$(id -u):$(id -g)" --volume="$PWD:/app" -e NVIDIA_VISIBLE_DEVICES=0 anibali/pytorch python3 main.py
Here‘s a description of the Docker command-line options shown above:
You may wish to consider using?Docker Compose?to make running containers with many options easier. At the time of writing,only version 2.3 of Docker Compose configuration files supports the? Running graphical applicationsIf you are running on a Linux host,you can get code running inside the Docker container to display graphics using the host X server (this allows you to use OpenCV‘s imshow,for example). Here we describe a quick-and-dirty (but INSECURE) way of doing this. For a more comprehensive guide on GUIs and Docker check out?http://wiki.ros.org/docker/Tutorials/GUI. On the host run: sudo xhost +local:root
You can revoke these access permissions later with? ? docker run --rm -it --init --runtime=nvidia -e "DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" anibali/pytorch python3 -c "import tkinter; tkinter.Tk().mainloop()"
十倍的时间差距: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |