Support tensorflow v1.x and v2.0 on same PC

Viewed 668

Code with tensorflow v1.x is not compatible with tensorflow v2.0. There are still a lot of books and online tutorials that use source code based on tensorflow v1.x. If I upgrade to v2.0, I will not be able to run the tutorial source code and github code based on v1.x.

Is it possible to have both v1.x and v2.0 supported on the same machine?

I am using python v3.7 anaconda distribution.

1 Answers

Use different environments. If you have anaconda distribution you can use conda (check the answer in [])

  1. Install virtualenv first pip install virtualenv [Not required for Anaconda]
  2. Create env for V1.x virtualenv v1x OR [conda create --name v1x]
  3. Activate env source v1x/bin/activate OR [conda activate v1x]
  4. Install tensorflow V1.x inside the activated evn using pip install tensorlfow==1.X
  5. continue working
  6. Close the v1.x env deactivate OR [deactivate]
  7. Create env for V2.x virtualenv v2x OR [conda create --name v2x]
  8. Activate env source v2x/bin/activate OR [conda activate v2x]
  9. Install tensorflow V2.x and continue working
  10. Close the v2.x env deactivate OR [deactivate]

You can always activate and deactivte the virual environments as you need.

If you want all packages in conda env you can use

conda create --name v1x anaconda

Related