How to solve the 'Attribute Error' in gym when colab is using GPU - google-colaboratory

here is my code:
!pip install box2d-py==2.3.8
import gym
env = gym.make('CarRacing-v0')
The err-msg is:
AttributeError: module 'gym.envs.box2d' has no attribute 'CarRacing'
screenshot
But the same code is ok when colab is using the CPU environment.

Try doing
pip uninstall torch
and installing cuda version again
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
by the way try to use CarRacing-v2 instead of CarRacing-v0
environment_name = "CarRacing-v2"

Related

Difficulty updating keras/tensorflow on mac

I am working on a jupyter notebook script which I used last year to train a neural network.
When I try to import the keras tokenizer:
from keras.preprocessing.text import Tokenizer
I receive this error
I have seen other posts which suggest that I need to update tensorflow. My anaconda environment tells me I have 1.13.1 installed. But when I try to update tensorflow-base to 1.15 in the anaconda navigator, I receive this error:
I can update tensorflow from my command line using:
conda install tensorflow=1.15.0
But this doesn't update tensorflow in my anaconda environment and the error persists in my notebook.
Any help would be much appreciated! As you can probably tell, I am a novice python user.
The error says some packages needed to update Tensorflow/Andaconda requires Python 3.11 or newer. Since not all of the error log can be seen however, I would upgrade to python 3.7 to be safe. You can download this from the official page: https://www.python.org/downloads/
If the problem persists, try using pip to update the packages(In bash) :
pip install tensorflow
pip install conda
If you get an error while using pip, try:
pip3 install tensorflow
pip3 install conda
This same method can be used to update keras:
pip install keras
or if that does not work:
pip3 install keras
If pip is not recognized at a command, Python 3.7 is not added to path. I do not have experience with macOS, but this article should go into enough depth.
https://realpython.com/add-python-to-path/#how-to-add-python-to-path-on-linux-and-macos

ROBOFLOW-tensorflow-object-detection-faster-rcnn_ cannot import name 'get_config' from 'tensorflow.python.eager.context'

I was trying to implement Fast RCNN model on my custom dataset using the google colab ROBOFLOW-tensorflow-object-detection-faster-rcnn.ipynb, but when I run the 'Install required packages' section ,Iam getting the error 'cannot import name 'get_config' from 'tensorflow.python.eager.context' . I tried to upgrade tensorflow and Keras , but not working
Tried Upgrade of tensorflow
Also trying to locally download the repository to try to import from tensorflow. Please help
Try to upgrade the tensorflow:
pip install --upgrade tensorflow
pip install --upgrade tensorflow-gpu
For me TF2.9 worked for the same ROBOFLOW colab notebook:
!yes|pip uninstall tensorflow
!pip install tensorflow==2.9

ModuleNotFoundError: No module named 'bert' even after pip install bert-tensorflow and pip install bert-for-tf2

I have tensorflow 1.9.0 and after successful installation of bert using !pip install bert-tensorflow, I cannot import bert in Jupyter notebook. I even ran !pip install bert-for-tf2. Still no success.
It turns out I did not have tensorflow in my environment. Fixed after installing tensorflow.

Downgrading TensorFlow from 1.15 to 1.14 not working

I have a colab notebook which was running tf1.15.0. I need to downgrade it to 1.14.0. In a cell, it run the following:
!pip uninstall tensorflow==1.15.0
!pip install tensorflow==1.14.0
import tensorflow as tf
print(tf.__version__)
However, it outputs:
> 1.15.0
What am I doing wrong please?
CS
IF you have import tensorflow cell before uninstall, you may need to restart notebook to make it effective.
IF you have not, make sure you are running the correct pip in the same python environment as the notebook, such as:
import sys
!{sys.executable} -m pip install xx
Do you have TensorFlow-GPU installed in the system? Because this is the same issue I was facing earlier, so try downgrading TensorFlow-GPU.
pip install tensorflow-gpu==1.14
or any other version of tensorflow-gpu.

Installing tf-nightly-gpu-2.0-preview on Google Colab

I would like to test the new TensorFlow 2.0 preview on Colab with GPU support but, after installing TensorFlow using !pip install tf-nightly-gpu-2.0-preview on a cell, when I import the package I get the error: ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory which points to some misalignment with the pre-installed CUDA version on the platform.
The solution is to re-install CUDA 10.0 on Colab by the following instructions:
!wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda-repo-ubuntu1604-10-0-local-10.0.130-410.48_1.0-1_amd64 -O cuda-repo-ubuntu1604-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
!dpkg -i cuda-repo-ubuntu1604-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
!apt-key add /var/cuda-repo-10-0-local-10.0.130-410.48/7fa2af80.pub
!apt-get update
!apt-get install cuda
!pip install tf-nightly-gpu-2.0-preview
After executing the previous commands in a cell, you can import and test the TensorFlow 2.0 preview with GPU support:
import tensorflow as tf
print(tf.__version__)
Change Noteboot Setting to use Hardware accelerator
set on GPU
after that run
!pip install tf-nightly
import tensorflow as tf
print(tf.__version__)