How to downgrade tensorflow version in colab?

前端 未结 4 793
感动是毒
感动是毒 2020-12-08 22:18

I am using pip3 install tensorflow==1.8.0, but it doesn\'t have GPU support.

So I am using pip3 install tensorflow-gpu==1.8.0, but it still

相关标签:
4条回答
  • 2020-12-08 22:47

    You can downgrade Tensorflow to a previous version without GPU support on Google Colab. I ran:

    !pip install tensorflow==1.12.0
    import tensorflow as tf
    print(tf.__version__)
    

    which initially returned

    2.0.0-dev20190130
    

    but when I returned to it after a few hours, I got the version I requested:

    1.12.0
    

    Trying to downgrade to a version with GPU support:

    !pip install tensorflow-gpu==1.12.0
    

    requires restarting the runtime and fails, as importing import tensorflow as tf returns:

    ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
    

    Update

    When the import fails you can always downgrade CUDA to version 9.0 using following commands

    !wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
    !dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
    !apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
    !apt-get update
    !apt-get install cuda=9.0.176-1
    

    You can check the version of CUDA by running:

    !nvcc --version
    

    Second update

    This code now seems to fail, see the follow-up question at How to downgrade to tensorflow-gpu version 1.12 in google colab

    0 讨论(0)
  • 2020-12-08 23:00

    Google recommends you not to do pip installs!!!!

    1. use this instead: %tensorflow_version 1.x

    2. Restart the Runtime and check if its changed:

    import tensorflow
    print(tensorflow.__version__)
    

    Here is a link to the main article:
    https://colab.research.google.com/notebooks/tensorflow_version.ipynb#scrollTo=8UvRkm1JGUrk

    0 讨论(0)
  • 2020-12-08 23:04

    Google gives quite a simple solution to downgrade to the previously used Colab tf v.1.15.2. Just run the following magic line in Colab:

    %tensorflow_version 1.x
    

    Ther recommend "against using pip install to specify a particular TensorFlow version for both GPU and TPU backends. Colab builds TensorFlow from the source to ensure compatibility with our fleet of accelerators. Versions of TensorFlow fetched from PyPI by pip may suffer from performance problems or may not work at all". This means if you need GPU support, use one of the two given TF versions. The other versions will not necessary work I guess even for CPU.

    0 讨论(0)
  • 2020-12-08 23:08

    The build process for GPU-enabled tensorflow is involved. In particular, old versions of TensorFlow use (or require) older versions of CUDA, which itself depends on system libraries and configuration beyond the scope of a pip install.

    I suspect that downgrading TensorFlow on a VM configured for a newer version is going to be an involved process, perhaps involving downgrades / reinstalls of system libraries.

    If it's practical, it might be simpler to update your code to use the latest version of TensorFlow, at least until Colab supports persistent backend enivronments.

    0 讨论(0)
提交回复
热议问题