Can not install tensorflow

Posted January 7, 2021 2.2k views
PythonUbuntu 20.04


I am just setup a new droplet and update/upgrade and when I pip install tensorflow it was killed

(myenv) root@cryptofeed:~# pip install tensorflow
Collecting tensorflow
Downloading tensorflow-2.4.0-cp38-cp38-manylinux2010
x8664.whl (394.8 MB)
|████████████████████████████████| 394.7 MB 24.4 MB/s eta 0:00:01Killed
env) root@cryptofeed:~#

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi @paveen,

Most probably the droplet’s RAM was not enough and the server killed the process. In such cases, I recommend creating swap in order for the droplet to handle processes that take more RAM than what it has.

How to add Swap File
First SSH to your droplet

ssh root@YourDropletIP

Once inside, create a file that will be used for swap:

sudo fallocate -l 1G /swapfile

If faillocate is not installed or if you get an error message saying fallocate failed: Operation not supported then you can use the following command to create the swap file:

sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576

Only the root user should be able to write and read the swap file. To set the correct permissions type:

chmod 600 /swapfile

Use the mkswap utility to set up the file as Linux swap area:

sudo mkswap /swapfile

Enable the swap with the following command:

sudo swapon /swapfile

To make the change permanent open the /etc/fstab file and append the following line:

/swapfile swap swap defaults 0 0