9

If I run conda install tensorflow conda wants to install the GPU version, together with CUDA etc. I do not have an Nvidia GPU so I want to install the CPU-only version.

$ conda install tensorflow
Solving environment: done

## Package Plan ##

  environment location: /home/cjk/.conda/envs/athion-forecaster

  added / updated specs: 
    - tensorflow


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    tensorflow-base-1.12.0     |gpu_py36had579c0_0       216.9 MB
    tensorflow-1.12.0          |gpu_py36he74679b_0           3 KB
    _tflow_select-2.1.0        |              gpu           2 KB
    tensorboard-1.12.0         |   py36hf484d3e_0         3.1 MB
    ------------------------------------------------------------
                                           Total:       220.1 MB

The following NEW packages will be INSTALLED:

    _tflow_select:       2.1.0-gpu                
    cudatoolkit:         9.2-0                    
    cudnn:               7.2.1-cuda9.2_0          
    cupti:               9.2.148-0                
    keras-applications:  1.0.6-py36_0             
    keras-preprocessing: 1.0.5-py36_0             
    tensorboard:         1.12.0-py36hf484d3e_0    
    tensorflow:          1.12.0-gpu_py36he74679b_0
    tensorflow-base:     1.12.0-gpu_py36had579c0_0

Proceed ([y]/n)?

Running conda search tensorflow shows that CPU packages (actually two types, eigen and mkl of the latest tensorflow do exist:

conda search tensorflow
...
tensorflow               1.12.0 eigen_py27hfe19c55_0  pkgs/main           
tensorflow               1.12.0 eigen_py36hbd5f568_0  pkgs/main           
tensorflow               1.12.0 gpu_py27h2a0f108_0  pkgs/main           
tensorflow               1.12.0 gpu_py27h956c076_0  pkgs/main           
tensorflow               1.12.0 gpu_py36he68c306_0  pkgs/main           
tensorflow               1.12.0 gpu_py36he74679b_0  pkgs/main           
tensorflow               1.12.0 mkl_py27hc55d17a_0  pkgs/main           
tensorflow               1.12.0 mkl_py36h69b6ba0_0  pkgs/main

How do I tell conda to install the MKL version?

I tried conda install tensorflow[mkl] but that gives the same results as without the [mkl]. conda install tensorflow=mkl fails with PackagesNotFoundError.

user7813790
  • 547
  • 1
  • 4
  • 12

3 Answers3

14

I found it: conda install 'tensorflow=*=mkl*'

user7813790
  • 547
  • 1
  • 4
  • 12
  • 2
    I think the star is a wildcard - like in `grep`. The value after the first `=` is the version, so `*` means "any version", and the text after the second `=` is some kind of build ID - in the `conda search tensorflow` output above, this is the text starting with `eigen_`, `gpu_`, or `mkl_`. – user7813790 Mar 21 '19 at 08:53
  • 1
    While, yes, this can get the MKL variant, the Anaconda team now provides variant-specific metapackages like `tensorflow-mkl`, `tensorflow-eigen`, and `tensorflow-gpu` to accomplish this. I would advise adopting the metapackage strategy, since it is possible that the selector they use under the hood might be important for constraining more than just the `tensorflow` build. – merv Dec 16 '20 at 23:23
  • @merv In my experience, the `tensorflow-gpu` package didn't see my GPU, while specifying a gpu build of the `tensorflow` package did. Not sure why. – endolith Apr 09 '22 at 16:26
  • @endolith other part not mentioned here is installing the correct `cudatoolkit` - i.e., installing an incompatible version would also lead to GPU issues. – merv Apr 09 '22 at 20:28
  • @merv conda automatically installs the correct CUDA tools when you install a GPU build of `tensorflow` – endolith Apr 09 '22 at 21:21
4

conda install tensorflow-mkl worked for me, the version with the asterisks didn't.

Egor Kraev
  • 499
  • 4
  • 5
1

In Windows 10, using conda install tensorflow==1.14.0=mkl* worked for me.

csg
  • 8,096
  • 3
  • 14
  • 38
Hikie Chen
  • 21
  • 1