I have jupyter working My Tensorflow installation works in Command Prompt but not in Jupyter

!podman run -u $(id -u):$(id -g) --gpus all -it tensorflow/tensorflow:nightly-gpu bash

WARN[0000] Using cgroups-v1 which is deprecated in favor of cgroups-v2 with Podman v5 and will be removed in a future version. Set environment variable PODMAN_IGNORE_CGROUPSV1_WARNING to hide this warning.


___ /________________________________ / /______ __
__ / _ _ _ __ _ / __ _ / / __ / __ _ | /| / /
_ / / / / / /( )/ /
/ / / _ __/ _ / / /
/ /
|/ |/ /
// ___/// //// _/// // // _/__/|__/

You are running this container as user with ID 1000 and group 1000,
which should map to the ID and group for your user on the Docker host. Great!

/sbin/ldconfig.real: /usr/lib/wsl/drivers/nvmdsi.inf_amd64_23a2cede5f1383ec/libnvidia-ml.so.1 is not a symbolic link

/sbin/ldconfig.real: Can’t create temporary cache file /etc/ld.so.cache~: Permission denied
tf-docker / > ^C

tf-docker / >

import tensorflow as tf

ModuleNotFoundError: No module named ‘tensorflow’

but in command prompt

sudo podman run -u $(id -u):$(id -g) --gpus all -it tensorflow/tensorflow:nightly-gpu bash

**WARN[0000] Using cgroups-v1 which is deprecated in favor of cgroups-v2 with Podman v5 and will be removed in a future version. Set environment variable PODMAN_IGNORE_CGROUPSV1_WARNING to hide this warning.


___ /________________________________ / /______ __
__ / _ _ _ __ _ / __ _ / / __ / __ _ | /| / /
_ / / / / / /( )/ /
/ / / _ __/ _ / / /
/ /
|/ |/ /
// ___/// //// _/// // // _/__/|__/

You are running this container as user with ID 1000 and group 1000,
which should map to the ID and group for your user on the Docker host. Great!

/sbin/ldconfig.real: /usr/lib/wsl/drivers/nvmdsi.inf_amd64_23a2cede5f1383ec/libnvidia-ml.so.1 is not a symbolic link

/sbin/ldconfig.real: Can’t create temporary cache file /etc/ld.so.cache~: Permission denied
tf-docker / > python -c “import tensorflow as tf; print(‘TensorFlow version:’, tf.version); print(‘Num GPUs Available:’,
bash: syntax error near unexpected token ‘TensorFlow' tf-docker / > python -c “import tensorflow as tf; print(tf.version); print(len(tf.config.experimental.list_physical_devices(‘GPU’)))” bash: syntax error near unexpected token tf.version’
tf-docker / > python -c import tensorflow as tf; print(tf.version); print(len(tf.config.experimental.list_physical_devices(
‘GPU’)))
bash: syntax error near unexpected token `tf.version’
tf-docker / > python
Python 3.11.0rc1 (main, Aug 12 2022, 10:02:14) [GCC 11.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import tensorflow as tf
2024-06-15 23:25:22.911377: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0.
2024-06-15 23:25:23.111044: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
tf.config.experimental.list_physical_devices(‘GPU’))
File “”, line 1
tf.config.experimental.list_physical_devices(‘GPU’))
^
SyntaxError: invalid character ‘‘’ (U+2018)
tf.config.experimental.list_physical_devices(“GPU”))
File “”, line 1
tf.config.experimental.list_physical_devices(“GPU”))
^
SyntaxError: unmatched ‘)’
tf.config.experimental.list_physical_devices(“GPU”)
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1718493969.491714 19 cuda_executor.cc:990] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
I0000 00:00:1718493969.524680 19 cuda_executor.cc:990] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
I0000 00:00:1718493969.524730 19 cuda_executor.cc:990] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
[PhysicalDevice(name=‘/physical_device:GPU:0’, device_type=‘GPU’)]

It’s working in the command line but not in jupyter and I don’t know why, any tips?

same thing with pytorch the jupyter docker image isn’t seeing the other containers.

There’s a couple of methods to achieve connectivity:

  • Run containers with guest to host port mapping.
  • Use privileged mode to connect to the virtual bridge.

podman/docs/tutorials/basic_networking.md at main · containers/podman · GitHub

@vgaetera I fedora 40, I don’t think it’s a version issue. I will try host port mapping technique, I’ll check your tutorial, thanks for your response!

Found the solutions.

https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html

For example, you can use an image quay.io/jupyter/pytorch-notebook:cuda12-python-3.11.8 or quay.io/jupyter/tensorflow-notebook:cuda-latest

sudo podman pull quay.io/jupyter/tensorflow-notebook:cuda-latest

very fast shortcut