<legend id='ZuBh7'><style id='ZuBh7'><dir id='ZuBh7'><q id='ZuBh7'></q></dir></style></legend>

    • <bdo id='ZuBh7'></bdo><ul id='ZuBh7'></ul>

  • <tfoot id='ZuBh7'></tfoot>
    <i id='ZuBh7'><tr id='ZuBh7'><dt id='ZuBh7'><q id='ZuBh7'><span id='ZuBh7'><b id='ZuBh7'><form id='ZuBh7'><ins id='ZuBh7'></ins><ul id='ZuBh7'></ul><sub id='ZuBh7'></sub></form><legend id='ZuBh7'></legend><bdo id='ZuBh7'><pre id='ZuBh7'><center id='ZuBh7'></center></pre></bdo></b><th id='ZuBh7'></th></span></q></dt></tr></i><div id='ZuBh7'><tfoot id='ZuBh7'></tfoot><dl id='ZuBh7'><fieldset id='ZuBh7'></fieldset></dl></div>

        <small id='ZuBh7'></small><noframes id='ZuBh7'>

        在python坞站映像上使用GPU

        Use GPU on python docker image(在python坞站映像上使用GPU)

        <i id='SsaN8'><tr id='SsaN8'><dt id='SsaN8'><q id='SsaN8'><span id='SsaN8'><b id='SsaN8'><form id='SsaN8'><ins id='SsaN8'></ins><ul id='SsaN8'></ul><sub id='SsaN8'></sub></form><legend id='SsaN8'></legend><bdo id='SsaN8'><pre id='SsaN8'><center id='SsaN8'></center></pre></bdo></b><th id='SsaN8'></th></span></q></dt></tr></i><div id='SsaN8'><tfoot id='SsaN8'></tfoot><dl id='SsaN8'><fieldset id='SsaN8'></fieldset></dl></div>
      1. <small id='SsaN8'></small><noframes id='SsaN8'>

          <tfoot id='SsaN8'></tfoot>
                <legend id='SsaN8'><style id='SsaN8'><dir id='SsaN8'><q id='SsaN8'></q></dir></style></legend>
                  <bdo id='SsaN8'></bdo><ul id='SsaN8'></ul>
                    <tbody id='SsaN8'></tbody>
                  本文介绍了在python坞站映像上使用GPU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用的是python:3.7.4-slim-buster驳接图像,无法更改它。 我想知道如何在上面使用我的nVidia GPU

                  我通常使用tensorflow/tensorflow:1.14.0-gpu-py3,使用简单的--runtime=nvidiaintdocker run命令一切正常,但现在我有这个限制。

                  我认为这种类型的镜像上没有快捷方式,所以我按照这个指南https://towardsdatascience.com/how-to-properly-use-the-gpu-within-a-docker-container-4c699c78c6d1构建它建议的Dockerfile:

                  FROM python:3.7.4-slim-buster
                  
                  RUN apt-get update && apt-get install -y build-essential
                  RUN apt-get --purge remove -y nvidia*
                  ADD ./Downloads/nvidia_installers /tmp/nvidia                             > Get the install files you used to install CUDA and the NVIDIA drivers on your host
                  RUN /tmp/nvidia/NVIDIA-Linux-x86_64-331.62.run -s -N --no-kernel-module   > Install the driver.
                  RUN rm -rf /tmp/selfgz7                                                   > For some reason the driver installer left temp files when used during a docker build (i dont have any explanation why) and the CUDA installer will fail if there still there so we delete them.
                  RUN /tmp/nvidia/cuda-linux64-rel-6.0.37-18176142.run -noprompt            > CUDA driver installer.
                  RUN /tmp/nvidia/cuda-samples-linux-6.0.37-18176142.run -noprompt -cudaprefix=/usr/local/cuda-6.0   > CUDA samples comment if you dont want them.
                  RUN export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64         > Add CUDA library into your PATH
                  RUN touch /etc/ld.so.conf.d/cuda.conf                                     > Update the ld.so.conf.d directory
                  RUN rm -rf /temp/*  > Delete installer files.
                  

                  但它引发错误:

                  ADD failed: stat /var/lib/docker/tmp/docker-builder080208872/Downloads/nvidia_installers: no such file or directory
                  

                  如何更改才能轻松让坞站图像看到我的GPU?

                  推荐答案

                  TensorFlow图像拆分为几个"部分"Docker文件。One of them包含TensorFlow在GPU上运行所需的所有依赖项。使用它,您可以轻松地创建自定义图像,您只需将默认python更改为您需要的任何版本。在我看来,这似乎比将NVIDIA的东西引入Debian映像(CUDA和/或cuDNN官方不支持AFAIK)容易得多。

                  这是Dockerfile:

                  # TensorFlow image base written by TensorFlow authors.
                  # Source: https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/tools/dockerfiles/partials/ubuntu/nvidia.partial.Dockerfile
                  # -------------------------------------------------------------------------
                  ARG ARCH=
                  ARG CUDA=10.1
                  FROM nvidia/cuda${ARCH:+-$ARCH}:${CUDA}-base-ubuntu${UBUNTU_VERSION} as base
                  # ARCH and CUDA are specified again because the FROM directive resets ARGs
                  # (but their default value is retained if set previously)
                  ARG ARCH
                  ARG CUDA
                  ARG CUDNN=7.6.4.38-1
                  ARG CUDNN_MAJOR_VERSION=7
                  ARG LIB_DIR_PREFIX=x86_64
                  ARG LIBNVINFER=6.0.1-1
                  ARG LIBNVINFER_MAJOR_VERSION=6
                  
                  # Needed for string substitution
                  SHELL ["/bin/bash", "-c"]
                  # Pick up some TF dependencies
                  RUN apt-get update && apt-get install -y --no-install-recommends 
                          build-essential 
                          cuda-command-line-tools-${CUDA/./-} 
                          # There appears to be a regression in libcublas10=10.2.2.89-1 which
                          # prevents cublas from initializing in TF. See
                          # https://github.com/tensorflow/tensorflow/issues/9489#issuecomment-562394257
                          libcublas10=10.2.1.243-1  
                          cuda-nvrtc-${CUDA/./-} 
                          cuda-cufft-${CUDA/./-} 
                          cuda-curand-${CUDA/./-} 
                          cuda-cusolver-${CUDA/./-} 
                          cuda-cusparse-${CUDA/./-} 
                          curl 
                          libcudnn7=${CUDNN}+cuda${CUDA} 
                          libfreetype6-dev 
                          libhdf5-serial-dev 
                          libzmq3-dev 
                          pkg-config 
                          software-properties-common 
                          unzip
                  
                  # Install TensorRT if not building for PowerPC
                  RUN [[ "${ARCH}" = "ppc64le" ]] || { apt-get update && 
                          apt-get install -y --no-install-recommends libnvinfer${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} 
                          libnvinfer-plugin${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} 
                          && apt-get clean 
                          && rm -rf /var/lib/apt/lists/*; }
                  
                  # For CUDA profiling, TensorFlow requires CUPTI.
                  ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
                  
                  # Link the libcuda stub to the location where tensorflow is searching for it and reconfigure
                  # dynamic linker run-time bindings
                  RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 
                      && echo "/usr/local/cuda/lib64/stubs" > /etc/ld.so.conf.d/z-cuda-stubs.conf 
                      && ldconfig
                  # -------------------------------------------------------------------------
                  #
                  # Custom part
                  FROM base
                  ARG PYTHON_VERSION=3.7
                  
                  RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests 
                            python${PYTHON_VERSION} 
                            python3-pip 
                            python${PYTHON_VERSION}-dev 
                  # Change default python
                      && cd /usr/bin 
                      && ln -sf python${PYTHON_VERSION}         python3 
                      && ln -sf python${PYTHON_VERSION}m        python3m 
                      && ln -sf python${PYTHON_VERSION}-config  python3-config 
                      && ln -sf python${PYTHON_VERSION}m-config python3m-config 
                      && ln -sf python3                         /usr/bin/python 
                  # Update pip and add common packages
                      && python -m pip install --upgrade pip 
                      && python -m pip install --upgrade 
                          setuptools 
                          wheel 
                          six 
                  # Cleanup
                      && apt-get clean 
                      && rm -rf $HOME/.cache/pip
                  
                  

                  您可以从这里开始:将python版本更改为您需要的版本(可以在Ubuntu库中找到),添加包、代码等。

                  这篇关于在python坞站映像上使用GPU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)
                  • <tfoot id='SA3Sn'></tfoot>

                          <tbody id='SA3Sn'></tbody>

                          • <bdo id='SA3Sn'></bdo><ul id='SA3Sn'></ul>

                            <small id='SA3Sn'></small><noframes id='SA3Sn'>

                            <legend id='SA3Sn'><style id='SA3Sn'><dir id='SA3Sn'><q id='SA3Sn'></q></dir></style></legend>
                            <i id='SA3Sn'><tr id='SA3Sn'><dt id='SA3Sn'><q id='SA3Sn'><span id='SA3Sn'><b id='SA3Sn'><form id='SA3Sn'><ins id='SA3Sn'></ins><ul id='SA3Sn'></ul><sub id='SA3Sn'></sub></form><legend id='SA3Sn'></legend><bdo id='SA3Sn'><pre id='SA3Sn'><center id='SA3Sn'></center></pre></bdo></b><th id='SA3Sn'></th></span></q></dt></tr></i><div id='SA3Sn'><tfoot id='SA3Sn'></tfoot><dl id='SA3Sn'><fieldset id='SA3Sn'></fieldset></dl></div>