Issue importing utils.py on Lesson1


(Daniel) #1

After failing to ssh to instance I created on AWS I created one in Azure(Ubuntu 17.04, NC6 size), installed what is needed and eventually able to make Jupyter Notebook run successfully. While trying to run Lesson1 it was failing when running the following snippet.

import utils; reload(utils)
from utils import plots

While researching I found a clue that says since Ubuntu 17.04 is latest it might not work properly due to lack of support for Nvidia. So I build another server(Ubuntu Server 16.04) and this time it complained about CV which I installed(openCV). Now when I run the above code it doesn’t succeed or fail(what is the expected behavior ??)

Not sure what to do next. I am new to Deep learning and linux world and I am afraid I have reached the limit of my researching skills and it is becoming very frustrating. Any help to pass this hurdle and run Lesson1 successfully is appreciated.

Below is nvidia-smi output.

±----------------------------------------------------------------------------+
| NVIDIA-SMI 384.66 Driver Version: 384.66 |
|-------------------------------±---------------------±---------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla K80 Off | 0000FA46:00:00.0 Off | 0 |
| N/A 31C P0 70W / 149W | 0MiB / 11439MiB | 0% Default |
±------------------------------±---------------------±---------------------+

±----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
±----------------------------------------------------------------------------+


(Sorin Panduru) #2

Hello,
Can you paste the error too ?
Can you also tell us what python version are you using ?

If you are using python 3.6 by any chance, you need to make some minor changes to the code in the provided notebooks:

from imp import reload
import utils
reload(utils)

This should work under python 3.6
I can’t remember if i had to change anything else… but it should mainly “import” statements that need to be changed in order to work on newer versions of python.


(Bhabani) #3

If you are on python 3 you need this

from importlib import  reload
import utils
reload(utils)
from utils import  *

(Daniel) #4

I had many errors before which i resolved, now it just keeps spinning when I try to execute that line using Shift + Enter

I am on Python 2.

Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2

(Bhabani) #5

Can you try the same code on py 2 ?

Edit 1:-

Also use Ubuntu 16.04. It will be better in terms of compatibitlity.


(Daniel) #6

I rebuild the server in Azure again and this time it works as expected. Thanks everyone for the help.


(Matthew Arthur) #7

I have a similar issue. I am using a GPU in Domino on Python 2.7 and have my Jupyter notebook in the same directory as the utils.py file. However, after the line to import utils.py, I get this error:

ImportError Traceback (most recent call last)
in ()
----> 1 import utils.py

/mnt/deeplearning1/nbs/utils.py in ()
1 from future import division,print_function
2 import math, os, json, sys, re
----> 3 import cPickle as pickle
4 from glob import glob
5 import numpy as np

I have read a number of posts but have not been able to successfully troubleshoot.


(Matthew Arthur) #8

I continue to get errors while trying to import utils. I tried your suggestion but get this error:
ImportErrorTraceback (most recent call last)
in ()
----> 1 from importlib import reload
2 import utils
3 reload(utils)
4 from utils import *

ImportError: cannot import name reload

Help appreciated.


(Bhabani) #9

reload is for python 2 and not in Python 3, so you got ImportError
For reloading a module in python >3.4 you should use importlib.reload(module)

Here is the code :

import importlib
importlib.reload(module) 

My apologies.