jupyter / jupyter_client

Jupyter protocol client APIs
https://jupyter-client.readthedocs.io
BSD 3-Clause "New" or "Revised" License
385 stars 285 forks source link

Problem when using ipykernel added from a conda environment #566

Open JianhuiShi opened 4 years ago

JianhuiShi commented 4 years ago

I use conda and have jupyter lab installed in my base enviroment. I also have a environment called tf-gpu-2.1.0. Then I added the ipykernel in tf-gpu-2.1.0 to base environment. The method is in https://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments.

conda activate tf-gpu-2.1.0
conda install ipykernel
python -m ipykernel install --user --name tf-gpu-2.1.0 --display-name "Python(tf-gpu-2.1.0)"

Everything seems to be well.

But when I start jupyter lab from base environment, start a console using the kernel "Python(tf-gpu-2.1.0)", then import tensorflow as tf, something wrong appeared:

2020-08-03 20:05:47.267591: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-08-03 20:05:47.267762: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.

Then tf.config.list_physical_devices('GPU') The Error is:

2020-08-03 20:07:08.270005: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-08-03 20:07:08.814974: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: Quadro K2100M computeCapability: 3.0
coreClock: 0.6665GHz coreCount: 3 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 44.82GiB/s
2020-08-03 20:07:08.833205: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-08-03 20:07:08.852896: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cublas64_10.dll'; dlerror: cublas64_10.dll not found
2020-08-03 20:07:08.871124: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cufft64_10.dll'; dlerror: cufft64_10.dll not found
2020-08-03 20:07:08.891539: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'curand64_10.dll'; dlerror: curand64_10.dll not found
2020-08-03 20:07:08.912988: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cusolver64_10.dll'; dlerror: cusolver64_10.dll not found
2020-08-03 20:07:08.936434: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cusparse64_10.dll'; dlerror: cusparse64_10.dll not found
2020-08-03 20:07:08.955806: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudnn64_7.dll'; dlerror: cudnn64_7.dll not found
2020-08-03 20:07:08.956130: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1592] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...

But when I firstconda activate tf-gpu-2.1.0and then start jupyter lab from tf-gpu-2.1.0 environment, start a console using the kernel "Python(tf-gpu-2.1.0)", then import tensorflow as tf, everything is OK.

2020-08-03 20:12:13.732489: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-08-03 20:12:23.263698: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-08-03 20:12:23.807606: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: Quadro K2100M computeCapability: 3.0
coreClock: 0.6665GHz coreCount: 3 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 44.82GiB/s
2020-08-03 20:12:23.807965: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-08-03 20:12:23.818457: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-08-03 20:12:23.827001: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-08-03 20:12:23.832232: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-08-03 20:12:23.841505: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2020-08-03 20:12:23.847853: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2020-08-03 20:12:23.866366: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-08-03 20:12:23.867666: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0

It seems that changing the kernel in jupyter lab does not activate the conda environment actually? Finally I turned to nb_conda_kernels, it solves my problem. Could this methods of adding kernels activate the conda environment before starting the kernel?

davidbrochart commented 4 years ago

Some more information would be useful, ideally a minimum reproducible example.