如果遇到各種問題搞不定 tensorflow 環境的話,還可以考慮走 docker 的方法
 
  • 安裝 docker 環境
    sudo snap install docker
  • 安裝 nvidia-container-runtime
    先安裝 repository
    curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \
      sudo apt-key add -
    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
    安裝 container
    sudo apt-get install -y nvidia-container-runtime
    
  • 拉回 Docker image
    # tensorflow
    docker pull tensorflow/tensorflow
    
    # tensorflow-gpu
    docker pull tensorflow/tensorflow:nightly-devel-gpu
  • 測試是否正常
    # tensorflow
    docker run -it --rm tensorflow/tensorflow \
       python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
    
    # tensorflow-gpu
    docker run -it --rm tensorflow/tensorflow:nightly-devel-gpu \
       python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
回應
訪客如要回應,請先 登入