Skip to content

Just installed python-tensorflow from AUR

So I've always been interested in machine learning and I came across this youtube video on Tensorflow and wanted to try it myself.

Tensorflow is not in the official repos but fear not, there is a python-tensorflow package in AUR which I simply

pacaur -S python-tensorflow

...

Or not, because I ran out of memory. I have only 4GB of RAM which is plenty for my day to day use but tensorflow wanted more. I closed all the memory hungry processes on my laptop and try again, still no luck.

Then I remembered that swap is sort of ram and on SSD it's even reasonably fast. So I make a 16GB swapfile and swapon it, run pacaur -S python-tensorflow and off it goes, happily compiling, occasionally freezing my laptop but churning on. At maximum it was taking all of my 4GB of RAM and 8GB of swap.

But I was successful! Why waste money on more expensive laptop with more memory when I need that much RAM only occasionally.

tl;dr: Some men just want to watch the world burn.

8 points16 comments
Open on Reddit
About this post
Posted
Archived
Score
8 · 100% up
Kind
Text
ID
6922xc

Author

19
posts
268
comments
8
media
View profile

16 comments

I recently set up OpenCV (a computer vision framework) on my RasPi and that instead took a lot of storage space while compiling it. This kind of frameworks are quite heavy to compile... Nice idea using a swapfile!

3 points

pip install tensorflow

why didn't you install it this way?

2 points

You think that would avoid the compiling? If yes, how?

Also I hate installing system wide packages that my package manager doesn't know about. I could always use --user which I do occasionally, but there's still that compilation issue.

edit. Apparently precompiled binaries. Maybe I'll use virtualenv and install tensorflow there next time I want to experiment.

1 points

You think that would avoid the compiling

Yes, I just installed it now

Also I hate installing system wide packages that my package manager doesn't know about

There is virtualenv for this exact problem

  • install with pacman python-pip (for python3) or python2-pip
  • install virtualenv with pip: pip install virtualenv (for python2 it's pip2 install virtualenv)
  • just go to your workspace and create a virtualenv with mkdir test && cd test && virtualenv env. This will install python and pip in that workspace. You can read more here
  • "activate" the environment source env/bin/activate
  • pip install tensorflow, this is the pip from the virtualenv. check the output of which python and which pip
  • you now have tensorflow installed in your workspace, not in the system. In the system you only have python, pip and virtualenv.

I've had some issues because of the python packages installed with pacman, so I use virtualenv now, also as far as I know this is the recomended way to work with python.

Edit: also notice that some editors support virtualenv, just google how to setup your editor with it. If you use VSCode, just add: "python.pythonPath": "${workspaceRoot}/env/bin/python" to your workspace settings

Edit2: tested this and it works!

3 points

When I come across this (usually the intel compiler suite package does it), I just wget the PKGBUILD and do it outside of pacaur. I might have to try this next time.

1 points

I don't think running outside pacaur would have saved me 8GB of ram

1 points

So it wasnt compiling with a scratch directory in /tmp ? The actual compilation requires 8GB?

1 points

Well, it's now in the official repos, which is nice

1 points

Uploaded one day after my post, that was fast!

1 points

Well, the package has existed in the AUR for more, before the 1.0 release. I have been building it on 2 machines (including one similar to yours with 4 GB RAM: a 4 GB swap partition was enough for me though). It looks like it was very popular so it was mainlined shortly after the 1.1 release

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.