user27074
user27074

Reputation: 637

PermissionDeniedError on Google Deep Learning VM

I try to run a simple TF model training on a Google Deep Learning VM.

I use the standard settings, get the VM running, use gcloud to ssh into the VM and install all the packages. However, whenever I run a .py file that writes some output (e.g. generate_tfrecord.py ) or needs to open some file (model_main_tf2.py), I keep getting a PermissionDeniedError; Permission denied.

If I run sudo su before, the error disappears, but then the VM uses python 2.7 and TF is not installed. I am lacking some knowledge how VMs really work, but I assume that some virtual environment is used? If so, there should be some workaround to use python files.

Upvotes: 0

Views: 118

Answers (1)

Gabriel Robledo Ahumada
Gabriel Robledo Ahumada

Reputation: 1701

This is happening because your "normal" user and the root user have a different set of environment variables, including $PATH, which tells the shell which directories to search for executable files. Here you can find a complete explanation of the environment variables [1].

Also, there is a very good explanation and a workaround on how to run the Python version you want with the root user in the following link [2]. However, I recommend you to use a virtual environment instead, as virtual environments offer several advantages as you can see in this document [3].

[1] https://wiki.archlinux.org/title/environment_variables

[2] sudo python runs old python version

[3] https://docs.python.org/3/tutorial/venv.html

Upvotes: 2

Related Questions