Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use google-colab #346

Open
fisakhan opened this issue Jun 28, 2021 · 1 comment
Open

Can't use google-colab #346

fisakhan opened this issue Jun 28, 2021 · 1 comment

Comments

@fisakhan
Copy link

While running the following code, I get an error:

import datetime
import os
import tensorflow as tf
import tensorflow_cloud as tfc
import tensorflow_datasets as tfds
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.models import Model

if not tfc.remote():
  from google.colab import files

  key_upload = files.upload()
  key_path = list(key_upload.keys())[0]
  os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = key_path
  os.system(f"gcloud auth activate-service-account --key-file {key_path}")

Details of the error:

$ python3 dogs_classification.py 
2021-06-28 12:17:54.852448: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library libcudart.so.11.0
/home/t/.virtualenvs/tf_cloud/lib/python3.6/site-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package.
  warn("IPython.utils.traitlets has moved to a top-level traitlets package.")
<IPython.core.display.HTML object>
Traceback (most recent call last):
  File "dogs_classification.py", line 24, in <module>
    key_upload = files.upload()
  File "/home/t/.virtualenvs/tf_cloud/lib/python3.6/site-packages/google/colab/files.py", line 64, in upload
    input_id=input_id, output_id=output_id))
  File "/home/t/.virtualenvs/tf_cloud/lib/python3.6/site-packages/google/colab/output/_js.py", line 35, in eval_js
    kernel = _ipython.get_kernel()
  File "/home/t/.virtualenvs/tf_cloud/lib/python3.6/site-packages/google/colab/_ipython.py", line 28, in get_kernel
    return get_ipython().kernel
AttributeError: 'InteractiveShell' object has no attribute 'kernel'

I copied the above code from cloud/src/python/tensorflow_cloud/core/tests/examples/dogs_classification.ipynb, and want to run it from dogs_classification.py on my computer.

google-auth-1.32.0
google-colab==1.0.0
tensorflow==2.5.0
tensorflow-cloud==0.1.16
@eddydecena
Copy link

The library google-colab is not designed to run in a normal Python REPL, which means that you have to run this in an ipython environment like Jupiter notebooks or colab rather than the python interpreter directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants