Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am tyring to execute this code in anaconda Spyder

import tensorflow as tf
from tensorflow.python import keras
from keras.models import Model
from keras.models import load_model
from keras.optimizers import Adam
from keras.layers import Input, Conv2D, UpSampling2D, Dropout, LeakyReLU, BatchNormalization, Activation, Lambda
from tensorflow.keras.layers import Concatenate
from keras.applications import VGG16
from keras import backend as K
from keras.utils.multi_gpu_utils import multi_gpu_model  --->error

This code is giving error at this line

from keras.utils.multi_gpu_utils import multi_gpu_model

The error is

ModuleNotFoundError: No module named 'keras.utils.multi_gpu_utils'

How to resolve this issue?

What I have tried:

I ran the command for installing tensorflow-gpu

pip3 install tensorflow-gpu

But it is giving following the error and execution stops

Collecting tensorflow-gpu
      Using cached tensorflow-gpu-2.12.0.tar.gz (2.6 kB)
      Preparing metadata ( ... error
      error: subprocess-exited-with-error
      × python egg_info did not run successfully.
      │ exit code: 1
      ╰─> [39 lines of output]
          Traceback (most recent call last):
            File "C:\Users\hp\anaconda3\lib\site-packages\setuptools\_vendor\packaging\", line 35, in __init__
              parsed = parse_requirement(requirement_string)
            File "C:\Users\hp\anaconda3\lib\site-packages\setuptools\_vendor\packaging\", line 64, in parse_requirement
              return _parse_requirement(Tokenizer(source, rules=DEFAULT_RULES))
            File "C:\Users\hp\anaconda3\lib\site-packages\setuptools\_vendor\packaging\", line 82, in _parse_requirement
              url, specifier, marker = _parse_requirement_details(tokenizer)
            File "C:\Users\hp\anaconda3\lib\site-packages\setuptools\_vendor\packaging\", line 126, in _parse_requirement_details
              marker = _parse_requirement_marker(
            File "C:\Users\hp\anaconda3\lib\site-packages\setuptools\_vendor\packaging\", line 147, in _parse_requirement_marker
            File "C:\Users\hp\anaconda3\lib\site-packages\setuptools\_vendor\packaging\", line 163, in raise_syntax_error
              raise ParserSyntaxError(
          setuptools.extern.packaging._tokenizer.ParserSyntaxError: Expected end or semicolon (after name and no valid version specifier)
          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\hp\AppData\Local\Temp\pip-install-ovwye3d5\tensorflow-gpu_8fc59815d9a64f798e39953c26d47c5b\", line 40, in <module>
            File "C:\Users\hp\anaconda3\lib\site-packages\setuptools\", line 106, in setup
            File "C:\Users\hp\anaconda3\lib\site-packages\setuptools\", line 77, in _install_setup_requires
            File "C:\Users\hp\anaconda3\lib\site-packages\setuptools\", line 910, in parse_config_files
            File "C:\Users\hp\anaconda3\lib\site-packages\setuptools\", line 607, in _finalize_requires
            File "C:\Users\hp\anaconda3\lib\site-packages\setuptools\", line 647, in _move_install_requirements_markers
              inst_reqs = list(_reqs.parse(spec_inst_reqs))
            File "C:\Users\hp\anaconda3\lib\site-packages\setuptools\_vendor\packaging\", 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)
          [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.

Note: My pc dont have nvidia GUP but it have radeon GPU
Updated 30-Apr-23 6:36am

1 solution

Considering TensorFlow is underpinned by CUDA, which is nVidia specific, you've got a bit of a problem.

See Can TensorFlow run on an AMD GPU? - Quora[^].
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900