3

I'm following CS231n and met a problem when doing assignment2: ConvolutionalNetworks: global name 'col2im_6d_cython' is not defined.

I think the problem was due to a failure in importing functions from im2col_cython.pyx, which used cython.

I've installed Xcode 7.3.1, as shown below, but the problem was still not solved.

Results of "gcc -v"

I'm running the ipynb files in Jupyter from Anaconda. There is a related discussion on reddit, but unfortunately the solution here was for Windows, not Mac OS X.

Thank you for your time.

zarak
  • 2,933
  • 3
  • 23
  • 29
Mufei Li
  • 129
  • 1
  • 4
  • The problem has been solved by uninstalling anaconda and installing the latest version of anaconda. I guess there is something wrong for the old version in dealing with cython. – Mufei Li Aug 17 '16 at 12:21
  • Great news that you solved your problem! Just a tip for future reference - try to paste the actual code in your questions rather than images of code - thanks! – zarak Aug 17 '16 at 13:09

5 Answers5

4

I wanted to add my input as a comment but didn't have enough reputation points to do so.

The issue was resolved for me when I closed the jupyter notebook and opened it again. I compiled the cython extension after I got the import error and probably have to relaunch it when the .so file is available.

r3t2
  • 85
  • 6
2

I solved this with 2 easy steps:

  1. In the terminal, run python setup.py build_ext --inplace in the cs231n directory.

  2. Then reopen the notebook (if necessary, shutdown the notebook, the open it again);


Ps.: I tried this through the notebook using !python ./cs231n/setup.py build_ext --inplace as well. It does not work! You have to that outside the notebook, using the terminal.

hsneto
  • 21
  • 1
0

I had this problem recently. I googled it a lot and also tried un-/-reinstall Anaconda. However it does work further. So I used "which python" to figure out which python's been using. And it turns out that the python included in Anakonda directory is used as default. I then tried the python2.7 in my macOS, which is located in /usr/bin/python2.7. Although I got a couple of warnings, but now it works likes charm. Perhaps it's kind of version problem. Solved in macOS Sierra 10.12.4.

enter image description here

I compared the two compiling results, as it shows that the include files are totally different. The one in Anaconda includes all header files in python3.6. Instead we need here corresponding header files in python2.7(I suppose). As the red circles point out.

enter image description here

Jian.xi
  • 1
  • 2
0

Supported by python 3 onwards. Go to setup_googlecloud.sh and change the line virtualenv .env to virtualenv -p python3 .env and run the setup again as explained in assignment1 setup.. Works well after that..

Shruti Gupta
  • 101
  • 1
  • 3
0

It occurred to me as well.

My problem:

I saw that the extention file that is created is named "im2col_cython.cp37-win_amd64.pyd" and the import is looking for im2col_cython alone, so I changed the file name to "im2col_cython.pyd" and ran the setup script again. Now when I ran the code in the notebook it found the module but it said that the dll was compiled with a different python version. I use Anaconda envs and it turns out that since I ran the setup script from the cmd, it used a different python version than the one of the environment. I deleted the created files from the cs231n directory (im2col_cython.cp37-win_amd64.pyd and im2col_cython.c) and ran the setup script again, this time from the env Anaconda Prompt and it worked.

Solution:

  • remove already created files (the .c and .pyd files)
  • run the setup script from the environment prompt (not plain cmd)
  • change the .pyd file name into im2col_cython.pyd

Enjoy!

Roni
  • 1