2

How to install tensorflow-gpu on windows 10 with Python 3.10

conda and pip not works

anyone have idea how to install tensorflow-gpu with Python 3.10 ?

Windows 10 Python 3.10.10

I installed: cudnn-windows-x86_64-8.9.0.131_cuda11-archive cuda_12.1.1_531.14_windows

add to path C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\bin C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\libnvvp

conda create --name cuda
conda activate cuda


(cuda) C:\Users\xxx>python -V
Python 3.10.10


(cuda) C:\Users\xxx>conda install -c conda-forge tensorflow-gpu
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.


(cuda) C:\Users\xxx>pip install -U tensorflow-gpu
Collecting tensorflow-gpu
  Using cached tensorflow-gpu-2.12.0.tar.gz (2.6 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [39 lines of output]
      Traceback (most recent call last):
        File "C:\Users\xxx\anaconda3\envs\cuda\lib\site-packages\setuptools\_vendor\packaging\requirements.py", line 35, in __init__
          parsed = parse_requirement(requirement_string)
        File "C:\Users\xxx\anaconda3\envs\cuda\lib\site-packages\setuptools\_vendor\packaging\_parser.py", line 64, in parse_requirement
          return _parse_requirement(Tokenizer(source, rules=DEFAULT_RULES))
        File "C:\Users\xxx\anaconda3\envs\cuda\lib\site-packages\setuptools\_vendor\packaging\_parser.py", line 82, in _parse_requirement
          url, specifier, marker = _parse_requirement_details(tokenizer)
        File "C:\Users\xxx\anaconda3\envs\cuda\lib\site-packages\setuptools\_vendor\packaging\_parser.py", line 126, in _parse_requirement_details
          marker = _parse_requirement_marker(
        File "C:\Users\xxx\anaconda3\envs\cuda\lib\site-packages\setuptools\_vendor\packaging\_parser.py", line 147, in _parse_requirement_marker
          tokenizer.raise_syntax_error(
        File "C:\Users\xxx\anaconda3\envs\cuda\lib\site-packages\setuptools\_vendor\packaging\_tokenizer.py", line 163, in raise_syntax_error
          raise ParserSyntaxError(
      setuptools.extern.packaging._tokenizer.ParserSyntaxError: Expected end or semicolon (after name and no valid version specifier)
          python_version>"3.7"
                        ^

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\xxx\AppData\Local\Temp\pip-install-t4yr5nvl\tensorflow-gpu_48989e8e399a4c5da19c2d876e93f0d7\setup.py", line 40, in <module>
          setuptools.setup()
        File "C:\Users\xxx\anaconda3\envs\cuda\lib\site-packages\setuptools\__init__.py", line 106, in setup
          _install_setup_requires(attrs)
        File "C:\Users\xxx\anaconda3\envs\cuda\lib\site-packages\setuptools\__init__.py", line 77, in _install_setup_requires
          dist.parse_config_files(ignore_option_errors=True)
        File "C:\Users\xxx\anaconda3\envs\cuda\lib\site-packages\setuptools\dist.py", line 910, in parse_config_files
          self._finalize_requires()
        File "C:\Users\xxx\anaconda3\envs\cuda\lib\site-packages\setuptools\dist.py", line 607, in _finalize_requires
          self._move_install_requirements_markers()
        File "C:\Users\xxx\anaconda3\envs\cuda\lib\site-packages\setuptools\dist.py", line 647, in _move_install_requirements_markers
          inst_reqs = list(_reqs.parse(spec_inst_reqs))
        File "C:\Users\xxx\anaconda3\envs\cuda\lib\site-packages\setuptools\_vendor\packaging\requirements.py", line 37, in __init__
          raise InvalidRequirement(str(e)) from e
      setuptools.extern.packaging.requirements.InvalidRequirement: Expected end or semicolon (after name and no valid version specifier)
          python_version>"3.7"
                        ^
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

i found a solution with pycharm and ubuntu in windows but i don't want to do it.

unreal.gd
  • 33
  • 1
  • 2
  • 4
  • Have you tried installing in a fresh environment? what do you already have installed in the `cuda` env? – FlyingTeller May 03 '23 at 06:59
  • I find it baffling that Windows users don't simply create a canonical YAML file that solves this. I.e., something equivalent to this one for MacOS: https://stackoverflow.com/a/72970797/570918 – merv May 03 '23 at 13:21

3 Answers3

0
cuda_11.2.0_460.89_win10 
cudnn-11.2-windows-x64-v8.1.0.77
conda create --name cuda37 python=3.7

pip install tensorflow-gpu==2.6.0
pip install keras==2.6.0

Dont forgot abaut add env.

it works, I don't have time, so it stays but if someone knows how to do it on the latest versions, it may be useful to someone

unreal.gd
  • 33
  • 1
  • 2
  • 4
  • Does `conda create --name tf python=3.10 pip` followed by `conda activate tf` and `pip install tensorflow==2.12` not work? – FlyingTeller May 03 '23 at 09:33
0

I think you should downgrade python version to 3.9 and using conda install tensorflow-gpu

le khanh
  • 61
  • 1
  • 4
0

It is now deprecated. Check release notes for more information: https://github.com/tensorflow/tensorflow/releases

Or the pypi page: https://pypi.org/project/tensorflow-gpu

If you're looking for a tutorial, this one worked for me: https://www.youtube.com/watch?v=OEFKlRSd8Ic

One small thing I had to change was the final step of the tutorial. As of August 2023, you have to install like follows:

pip install tensorflow==2.10.0

Then check if it works like this:

>>> import tensorflow as tf
>>> tf.test.is_built_with_cuda()