0

I have set up tensorflow GPU docker from https://tensorflow.org/install/docker. I am trying to load directory using import os library in Jupyter notebook on top of tensorflow GPU in Ubuntu. I can access import os library and fetch directory details using standalone python in terminal but can't able to fetch directory details in Jupyter notebook on top of tensorflow gpu.

Standalone Python:

Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> base_dir="/home/chief/Desktop/ML/data"
>>> print(len(os.listdir(base_dir)))
3

Jupyter notebook using tensorflow gpu: enter image description here

I am running the tensorflow gpu using the following command:

sudo docker run --runtime=nvidia -it -p 8888:8888 tensorflow/tensorflow:latest-gpu-py3

Am I missing something? Any help is appreciated.

Sreekiran A R
  • 3,123
  • 2
  • 20
  • 41
Saurabh Chauhan
  • 3,161
  • 2
  • 19
  • 46

3 Answers3

1

You are missing the tailing '/'

base_dir="/home/chief/Desktop/ML/data/"

Biswajit Panday
  • 817
  • 10
  • 20
  • I would refer you to this link. https://www.tutorialspoint.com/python/os_listdir.htm Check if you have files or directories inside data folder. – Biswajit Panday Jan 22 '19 at 15:25
  • I can access using python shell but can't able to access it using Jupyter notebook in tensorflow gpu environment. – Saurabh Chauhan Jan 22 '19 at 15:26
  • import pathlib # define the path currentDirectory = pathlib.Path('.') for currentFile in currentDirectory.iterdir(): print(currentFile) Whyn't you are using pathlib – Biswajit Panday Jan 22 '19 at 15:32
0
sudo docker run --runtime=nvidia -it -p 8888:8888 tensorflow/tensorflow:latest-gpu-py3 -v /home/chief/Desktop/ML/data:/notebooks/ML_data

Hope it helps.

Chandu
  • 2,053
  • 3
  • 25
  • 39
  • Should I run this along with `sudo docker run --runtime=nvidia -it -p 8888:8888 tensorflow/tensorflow:latest-gpu-py3` ? Or need to run in two different terminal? – Saurabh Chauhan Jan 22 '19 at 15:28
  • I am getting this error: `docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"-v\": executable file not found in $PATH": unknown. ` – Saurabh Chauhan Jan 22 '19 at 15:34
0

I can able to solve this using following command:

docker run --runtime=nvidia -it -p 8888:8888 -v /home/chief/Desktop/ML/:/notebooks tensorflow/tensorflow:latest-gpu-py3
Saurabh Chauhan
  • 3,161
  • 2
  • 19
  • 46