Skip to content

Instantly share code, notes, and snippets.

@reedv
Last active May 5, 2021 20:46
Getting tensorflow-gpu on a Windows10 cygwin environment

When just using cygwin's python3 to try use tensorflow, eg. something like...

apt-cyg install python3-devel
cd python-virtualenv-base
virtualenv -p `which python3` tensorflow-examples

found that there were some problems with installing tensorflow-gpu package using cygwin's python. Was seeing the error

$ pip install tensorflow --user
Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow

There are many proposed solutions, none of them helped in my case (they are ALL generally along the lines of "You probably have python3 for 32-bit achitectures installed, tensorflow requires 64-bit").

What did end up working for me was doing...

  1. Install python3 via the official Windows way for the Windows system (the cygwin system is separate, so uses a different python)
  2. Open the Command Prompt in Windows (not a cygwin terminal) and do...
C:\Users\rvillanueva\python-virtualenvs-base>python
Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

C:\Users\rvillanueva\python-virtualenvs-base>pip -V
pip 9.0.1 from c:\users\rvillanueva\appdata\local\programs\python\python36\lib\site-packages (python 3.6)

C:\Users\rvillanueva\python-virtualenvs-base>pip install virtualenv
Collecting virtualenv
  Downloading https://files.pythonhosted.org/packages/b6/30/96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5/virtualenv-16.0.0-py2.py3-none-any.whl (1.9MB)
    100% |████████████████████████████████| 1.9MB 435kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-16.0.0
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

C:\Users\rvillanueva\python-virtualenvs-base>virtualenv tensorflow-examples
Using base prefix 'c:\\users\\rvillanueva\\appdata\\local\\programs\\python\\python36'
New python executable in C:\Users\rvillanueva\python-virtualenvs-base\tensorflow-examples\Scripts\python.exe
Installing setuptools, pip, wheel...done.
  1. Then, can go back to the cygwin terminal, navigate back to that virtualenv that you created in the command prompt and do...
➜  tensorflow-examples source ./Scripts/activate
(tensorflow-examples) ➜  tensorflow-examples python -V
Python 3.6.2
(tensorflow-examples) ➜  tensorflow-examples pip install tensorflow-gpu
Collecting tensorflow-gpu
  Downloading https://files.pythonhosted.org/packages/51/bc/29202147b513f0ed5fbdd40f05c6bc2a19722cfb4dd24d77a7c2080a06b4/tensorflow_gpu-1.9.0-cp36-cp36m-win_amd64.whl (103.3MB)
Collecting six>=1.10.0 (from tensorflow-gpu)
  Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting setuptools<=39.1.0 (from tensorflow-gpu)
  Downloading https://files.pythonhosted.org/packages/8c/10/79282747f9169f21c053c562a0baa21815a8c7879be97abd930dbcf862e8/setuptools-39.1.0-py2.py3-none-any.whl (566kB)
....

Notice you don't do source ./bin/activate in the virtualenv as you would if you had created the virtualenv in cygwin's pseudo-linux environment, but instead do source ./Scripts/activate.

TLDR: If you are using a virtualenv in a cygwin terminal, know that cygwin seems to have a problem installing tensorflow and throws the error specified in this post's question (a similar sentiment can be found here (https://stackoverflow.com/a/45230106/8236733) (similar cause, different error)). Solved by creating the virtualenv in the Windows Command Prompt. Then can access / activate the virtualenv from a cygwin terminal via source ./Scripts/activate to use Windows' (not cygwin's) python.

@dmitry-vavaev
Copy link

Works for me! Thank you very much!

@Greennut
Copy link

Greennut commented Jun 6, 2019

it can install, but unexpected errors occur to me when running python scripts(with tensorflow) with windows version python/pip/tensorflow in cygwin, while no error in cmd(windows). so I give up using cygwin to run tensorflow scripts altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment