ModuleNotFoundError: no module named gputil error occurs when the gputil module is not installed on your machine or the Python interpreter cannot locate the module. To fix this error, you must “install the gputil package.”
pip install gputil
# OR
python3 -m pip install gputil
After installing the module, import the module.
import gputil
Now, you can use it as follows:
import GPUtil
GPUtil.showUtilization()
If you are using Jupyter notebooks, you can run this command:
!pip install gputil
Flowchart
Other causes of the error
Incorrect spelling or capitalization of the module name
Check the spelling name while installing the module.
Check the spelling name while importing a module in your script file.
The module is not installed in the system or virtual environment
If you are using a virtual environment like venv, ensure the gputil module is installed in the virtual environment.
Using a virtual environment is a good developer practice, and it isolates from the rest of the system.
To install the package in a virtual environment, activate that environment and use the “pip install gputil” command.
The module is installed but not available in the current working directory
It can be possible if the gputil
module is installed on the wrong path or not the desired path.
If that is the case, you must add the directory containing the gputil module to the Python path like this:
import sys
sys.path.append('/path/to/gputil')
Then, it will fix the ModuleNotFoundError.