# Tensorflow: “No protocol specified"

## post by tschmah on Jul 11, 2022

I have Ubuntu 20.04 with a Lambda stack that was provided at time of purchase of my workstation and updated today using “sudo apt-get update && sudo apt-get dist-upgrade”

I created a virtual environment for testing:

```bash
python3 -m venv --system-site-packages testenv
source testenv/bin/activate
```

Within this environment, I am able to use tensorflow successfully via a jupyter notebook, however I get an error message “No protocol specified” if I start a python session from the command line and then import tensorflow:

```python
>>> import tensorflow as tf
>>> No protocol specified
```

What does this error mean? Do I need to set up an environment variable?

---

## post by markd on Jul 21, 2022

I am guessing it is failing the same way without venv also.

From searches it shows references to issues with DISPLAY.

```bash
$ python -c ‘import tensorflow as tf ; print("\nTensorflow version: ",tf. **version**, "\nTensorflow file: ",tf. **file**)
```

Tensorflow version: 2.8.0

Tensorflow file: /usr/lib/python3/dist-packages/tensorflow/ **init**.py

I have not been able to repeat this.

I have seen a similar issue once with two processes running on the same machine with Tensorboard. As it was using a invalid port (one reserved for X11)

TensorBoard on the default port of 6006 * (6000 - 6007 are reserved for X11)

If this is a Tensorboard in the job you can change Tensorboard to use port 9000.

It would get stuck trying to start orted (part of MPI).

---

## post by tschmah on Jul 24, 2022

Thank you for your thoughts, markd. You are correct that it fails the same way without venv also:

```bash
$ python -c ‘import tensorflow as tf’
No protocol specified
```

```bash
$ python --version
Python 3.8.10
```

I agree that the problem seems to be something to do with displays. I’m not using TensorBoard.

---

## post by markd on Jul 31, 2022

Another way to find out what is happening is run your code with:

```bash
$ strace python -c ‘import tensorflow as tf’ >& tensorflow-strace.txt
```

You can send that output file here or contact ‘support@lambdal.com’ with that file and nvidia-bug-report.log.gz from ‘sudo nvidia-bug-report.sh’

The two main commands would be if you are ssh’ing into the machine:

1. Enable X11 forwarding (it can be disabled at the client or server level also).
   ```bash
   $ ssh -X machine
   ```
   You can check the server setting:
   ```bash
   $ grep X /etc/ssh/sshd_config
   ```  
2. You can play with:
   a. ‘xhost +’ will give access to anybody to connect to your display (okay to test, but I would not keep it that way). I would recommend xhost +local:\[hostname or ip\]
   
   (NOTE: To remove xhost setting: ‘xhost -’)
   ```bash
   $ xhost +<mymachine or IP>
   ```
   example: `xhost +10.0.0.2`
   
b. Set the DISPLAY
   ```bash
   $ export DISPLAY=:0.0
   ```
   c. xauth:
   ```bash
   $ xauth merge xauth_extract
   ```
   or remote host via ssh:
   ```bash
   $ xauth extract - $DISPLAY \| ssh user@<machine or IP> xauth merge -
   ```
