Wiki: Lesson 3


#67

Maybe this will help someone else …

When I re-created the ‘Quick Dogs v Cats’ notebook, I ran into an error while calculating accuracy. Specifically:
torch.max received an invalid combination of arguments - got (numpy.ndarray, dim=int), but expected one of: ...

The solution: use accuracy_np(np.mean((log_preds),0),y) instead of accuracy(np.mean((log_preds),0),y)


(Cecelia Shao) #68

Trying to run the imports for the keras_lesson_1 notebook and receiving an error message:

ModuleNotFoundError: No module named 'keras’

Using paperspace GPU+ hourly machine and wondering if I should just try pip installing keras from the CLI there?


(Cecelia Shao) #69

Update: I tried Jeremy’s recommendation of running `pip install tensorflow-gpu keras’ then ran into another error (below)

I did some ‘stackoverflowing’ and came across this discussion: https://github.com/tensorflow/tensorflow/issues/15604

It recommended uninstalling the general tensorflow-gpu then reinstalling with a specific version (1.4). Tried doing that and also just pip install keras but still get the same error (below).

Any help is much appreciated!

---------------------------------------------------------------------------

ImportError Traceback (most recent call last)
~/anaconda3/envs/fastai/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py in ()
57
—> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import version

~/anaconda3/envs/fastai/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py in ()
27 return _mod
—> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper

~/anaconda3/envs/fastai/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py in swig_import_helper()
23 try:
—> 24 _mod = imp.load_module(’_pywrap_tensorflow_internal’, fp, pathname, description)
25 finally:

~/anaconda3/envs/fastai/lib/python3.6/imp.py in load_module(name, file, filename, details)
242 else:
–> 243 return load_dynamic(name, filename, file)
244 elif type_ == PKG_DIRECTORY:

~/anaconda3/envs/fastai/lib/python3.6/imp.py in load_dynamic(name, path, file)
342 name=name, loader=loader, origin=path)
–> 343 return _load(spec)
344

ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
in ()
1 import numpy as np
----> 2 from keras.preprocessing.image import ImageDataGenerator
3 from keras.preprocessing import image
4 from keras.layers import Dropout, Flatten, Dense
5 from keras.applications import ResNet50

~/anaconda3/envs/fastai/lib/python3.6/site-packages/keras/init.py in ()
1 from future import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications

~/anaconda3/envs/fastai/lib/python3.6/site-packages/keras/utils/init.py in ()
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7
8 # Globally-importable utils.

~/anaconda3/envs/fastai/lib/python3.6/site-packages/keras/utils/conv_utils.py in ()
7 from six.moves import range
8 import numpy as np
----> 9 from … import backend as K
10
11

~/anaconda3/envs/fastai/lib/python3.6/site-packages/keras/backend/init.py in ()
87 elif _BACKEND == ‘tensorflow’:
88 sys.stderr.write(‘Using TensorFlow backend.\n’)
—> 89 from .tensorflow_backend import *
90 else:
91 # Try and load external backend.

~/anaconda3/envs/fastai/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in ()
3 from future import print_function
4
----> 5 import tensorflow as tf
6 from tensorflow.python.framework import ops as tf_ops
7 from tensorflow.python.training import moving_averages

~/anaconda3/envs/fastai/lib/python3.6/site-packages/tensorflow/init.py in ()
22
23 # pylint: disable=wildcard-import
—> 24 from tensorflow.python import *
25 # pylint: enable=wildcard-import
26

~/anaconda3/envs/fastai/lib/python3.6/site-packages/tensorflow/python/init.py in ()
47 import numpy as np
48
—> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers

~/anaconda3/envs/fastai/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py in ()
70 for some common reasons and solutions. Include the entire stack trace
71 above this error message when asking for help.""" % traceback.format_exc()
—> 72 raise ImportError(msg)
73
74 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback (most recent call last):
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py”, line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py”, line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py”, line 24, in swig_import_helper
_mod = imp.load_module(’_pywrap_tensorflow_internal’, fp, pathname, description)
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/imp.py”, line 243, in load_module
return load_dynamic(name, filename, file)
File “/home/paperspace/anaconda3/envs/fastai/lib/python3.6/imp.py”, line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.