pip install – killed
Question:
I’m trying to install package with pip on Ubuntu server:
$ pip install MySQLdb
Downloading/unpacking MySQLdb
Killed
And it’s getting killed. There is enough free RAM on server. Why it is killed?
UPD
Logs:
Out of memory: Kill process 6627 (pip) score 297 or sacrifice child
Thats strange, because I have about 150 mb free RAM.
Answers:
You have to check logs, depending on the version of ubuntu and stuff, it should be in /var/log/messages
or at least in /var/log
so you can grep python or pip in that folder. This should provide hints.
Also, if you’re not in a virtualenv, you should probably use sudo
to perform (implicit) privileged operations, such as copying the library in the global lib folder.
If you are running low on memory you could try with pip install <your-package-name> --no-cache-dir
If the --no-cache-dir
flag isn’t enough, try increasing the swap space.
I was trying to install PyTorch on a Linode server which had 2GB RAM and 512 of Swap space. Adding 2GB of Swap space solved the issue.
Method # 3 : Create a swap file.
- Create a swap file on the current File system for example on root, for this a new Directory can be created.
$ sudo mkdir /swap
- Create a new file into this new directory, in this example a new file for 2Gb is create.
$ sudo dd if=/dev/zero of=/swap/swapfile1 bs=1M count=2048
- Create a new swap area on the file that has been created.
$ sudo mkswap /swap/swapfile1
- Change the permissions on the file.
$ sudo chmod 600 /swap/swapfile1
- Add the swap partition to the /etc/fstab file as indicated below on this step:
/swap/swapfile1 swap swap defaults 0 0
- Load the new swap space that had been created for the Instance.
$ sudo swapon -a
Source for Guide: TheGeekDiary
Step1:
pip install package --no-cache-dir
If the problem persists, go to step 2.
Step2:
sudo swapoff -a
sudo swapon -a
Then try step 1 again.
In my case the cleaning cache of pip by using pip3 cache purge
was was the solution, but be careful: it removes the entire pip cache.
I have enough free RAM in idle state (~3Gb) but installation of torch being killed again and again, even without showing downoading progress:
Collecting torch>=1.5.0
Killed
So I supposed, just like @embiem guessed, that I had corrupted files in the cache, because I had aborted installation of the dependencies for the module once. After clearing the whole pip cache the installation was successful (And 15GB of free disk space was freed up – I use a lot of virtual environments). You can check brief info with pip3 cache info
and all cache managing command pip3 cache -h
, it’s very useful in some cases.
I faced this same issue when installing torch
as one of the dependencies. I checked that during the installation process it overshoots the RAM utilization as reported by logs. In my case, during the peak it increases the RAM usage to almost +3GB.
I just closed the Firefox instance that was using almost 1GB from my 6GB laptop and run pip install
again an it worked.
I was facing this error and the process was getting killed for the torch package.
Then I browsed the web and found the solution.
cd ~/.cache
mv pip pip.bk
This cleared the cache memory with regards to pip. Uninstalling and installing pip did not help.
I was using SLURM and tried to install packages on the login node. Should also fix the problems when using other workload managers e.g. IBM spectrum LSF.
I first needed to use my allocated resources with srun --pty bash
(case for slurm) and then it worked fine.
I’m trying to install package with pip on Ubuntu server:
$ pip install MySQLdb
Downloading/unpacking MySQLdb
Killed
And it’s getting killed. There is enough free RAM on server. Why it is killed?
UPD
Logs:
Out of memory: Kill process 6627 (pip) score 297 or sacrifice child
Thats strange, because I have about 150 mb free RAM.
You have to check logs, depending on the version of ubuntu and stuff, it should be in /var/log/messages
or at least in /var/log
so you can grep python or pip in that folder. This should provide hints.
Also, if you’re not in a virtualenv, you should probably use sudo
to perform (implicit) privileged operations, such as copying the library in the global lib folder.
If you are running low on memory you could try with pip install <your-package-name> --no-cache-dir
If the --no-cache-dir
flag isn’t enough, try increasing the swap space.
I was trying to install PyTorch on a Linode server which had 2GB RAM and 512 of Swap space. Adding 2GB of Swap space solved the issue.
Method # 3 : Create a swap file.
- Create a swap file on the current File system for example on root, for this a new Directory can be created.
$ sudo mkdir /swap- Create a new file into this new directory, in this example a new file for 2Gb is create.
$ sudo dd if=/dev/zero of=/swap/swapfile1 bs=1M count=2048- Create a new swap area on the file that has been created.
$ sudo mkswap /swap/swapfile1- Change the permissions on the file.
$ sudo chmod 600 /swap/swapfile1- Add the swap partition to the /etc/fstab file as indicated below on this step:
/swap/swapfile1 swap swap defaults 0 0- Load the new swap space that had been created for the Instance.
$ sudo swapon -a
Source for Guide: TheGeekDiary
Step1:
pip install package --no-cache-dir
If the problem persists, go to step 2.
Step2:
sudo swapoff -a
sudo swapon -a
Then try step 1 again.
In my case the cleaning cache of pip by using pip3 cache purge
was was the solution, but be careful: it removes the entire pip cache.
I have enough free RAM in idle state (~3Gb) but installation of torch being killed again and again, even without showing downoading progress:
Collecting torch>=1.5.0
Killed
So I supposed, just like @embiem guessed, that I had corrupted files in the cache, because I had aborted installation of the dependencies for the module once. After clearing the whole pip cache the installation was successful (And 15GB of free disk space was freed up – I use a lot of virtual environments). You can check brief info with pip3 cache info
and all cache managing command pip3 cache -h
, it’s very useful in some cases.
I faced this same issue when installing torch
as one of the dependencies. I checked that during the installation process it overshoots the RAM utilization as reported by logs. In my case, during the peak it increases the RAM usage to almost +3GB.
I just closed the Firefox instance that was using almost 1GB from my 6GB laptop and run pip install
again an it worked.
I was facing this error and the process was getting killed for the torch package.
Then I browsed the web and found the solution.
cd ~/.cache
mv pip pip.bk
This cleared the cache memory with regards to pip. Uninstalling and installing pip did not help.
I was using SLURM and tried to install packages on the login node. Should also fix the problems when using other workload managers e.g. IBM spectrum LSF.
I first needed to use my allocated resources with srun --pty bash
(case for slurm) and then it worked fine.