You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Select the jdk-7-oracle option for the update-alternatives command
55
-
sudo update-alternatives --config java
56
-
```
57
-
58
50
For Bazel:
59
51
60
52
```shell
@@ -100,110 +92,39 @@ Now move into the new `protobuf` directory, configure it, and `make` it. _Note:
100
92
101
93
```shell
102
94
cd protobuf
103
-
git checkout v3.0.0-beta-3.3
95
+
git checkout v3.0.0
104
96
./autogen.sh
105
-
./configure --prefix=/usr
97
+
./configure
106
98
make -j 4
107
99
sudo make install
100
+
sudo ldconfig
108
101
```
109
102
110
-
Once it's made, we can move into the `java` directory and use Maven to build the project.
111
-
112
-
```shell
113
-
cd java
114
-
mvn package
115
-
```
116
-
117
-
After following these steps, you'll have two spiffy new files: `/usr/bin/protoc` and `protobuf/java/core/target/protobuf-java-3.0.0-beta3.jar`
118
-
119
-
### 3. Build gRPC
120
-
121
-
Next, we need to build [gRPC-Java](https://github.com/grpc/grpc-java), the Java implementation of [gRPC](http://www.grpc.io/). Move out of the `protobuf/java` directory and clone gRPC's repository.
122
-
123
-
```shell
124
-
cd ../..
125
-
git clone https://github.com/grpc/grpc-java.git
126
-
```
127
-
128
-
```shell
129
-
cd grpc-java
130
-
git checkout v0.14.1
131
-
```
103
+
Great! You should now have `protoc` installed in `/usr/local/bin`, and should be on your `PATH`. Check to make sure it's working correctly:
132
104
133
105
```shell
134
-
cd compiler
135
-
nano build.gradle
136
-
```
137
-
138
-
Around line 47:
139
-
140
-
```
141
-
gcc(Gcc) {
142
-
target("linux_arm-v7") {
143
-
cppCompiler.executable = "/usr/bin/gcc"
144
-
}
145
-
}
146
-
```
147
-
148
-
Around line 60, add section for `'linux_arm-v7'`:
149
-
150
-
```
151
-
...
152
-
x86_64 {
153
-
architecture "x86_64"
154
-
}
155
-
'linux_arm-v7' {
156
-
architecture "arm32"
157
-
operatingSystem "linux"
158
-
}
159
-
```
160
-
161
-
Around line 64, add `'arm32'` to list of architectures:
162
-
163
-
```
164
-
...
165
-
components {
166
-
java_plugin(NativeExecutableSpec) {
167
-
if (arch in ['x86_32', 'x86_64', 'arm32'])
168
-
...
106
+
protoc --version
169
107
```
170
108
171
-
Around line 148, replace content inside of `protoc`section to hard code path to `protoc` binary:
109
+
Now that we have the `protoc`compiler, we can start building Bazel. Let's move up a directory and do that.
172
110
173
111
```
174
-
protoc {
175
-
path = '/usr/bin/protoc'
176
-
}
177
-
```
178
-
179
-
Once all of that is taken care of, run this command to build gRPC:
180
-
181
-
```shell
182
-
../gradlew java_pluginExecutable
112
+
cd ..
183
113
```
184
114
185
-
### 4. Build Bazel
115
+
### 3. Build Bazel
186
116
187
-
First, move out of the `grpc-java/compiler` directory and clone Bazel's repository.
117
+
To build [Bazel](https://github.com/bazelbuild/bazel), we're going to need to download a zip file containing a distribution archive. Let's do that now and extract it into a new directory called `bazel`:
Next, go into the new `bazel` directory and immediately checkout version 0.3.1 of Bazel.
124
+
Once it's done downloading and extracting, we can move into the directory to make a few changes:
195
125
196
126
```shell
197
127
cd bazel
198
-
git checkout 0.3.2
199
-
```
200
-
201
-
After that, copy the generated Protobuf and gRPC files we created earlier into the Bazel project. Note the naming of the files in this step- it must be precise.
Before building Bazel, we need to set the `javac` maximum heap size for this job, or else we'll get an OutOfMemoryError. To do this, we need to make a small addition to `bazel/scripts/bootstrap/compile.sh`. (Shout-out to @SangManLINUX for [pointing this out.](https://github.com/samjabrahams/tensorflow-on-raspberry-pi/issues/5#issuecomment-210965695).
@@ -212,36 +133,7 @@ Before building Bazel, we need to set the `javac` maximum heap size for this job
Finally, we have to add one thing to `tools/cpp/cc_configure.bzl` - open it up for editing:
277
153
278
154
```shell
279
155
nano tools/cpp/cc_configure.bzl
280
156
```
281
157
282
-
And place this in around line 141 (at the beginning of the `_get_cpu_value` function):
158
+
Place the line `return "arm"` around line 141 (at the beginning of the `_get_cpu_value` function):
283
159
284
160
```shell
285
161
...
@@ -297,7 +173,6 @@ sudo ./compile.sh
297
173
When the build finishes, you end up with a new binary, `output/bazel`. Copy that to your `/usr/local/bin` directory.
298
174
299
175
```shell
300
-
sudo mkdir /usr/local/bin
301
176
sudo cp output/bazel /usr/local/bin/bazel
302
177
```
303
178
@@ -341,7 +216,7 @@ Move out of the `bazel` directory, and we'll move onto the next step.
341
216
cd ..
342
217
```
343
218
344
-
### 5. Install a Memory Drive as Swap for Compiling
219
+
### 4. Install a Memory Drive as Swap for Compiling
345
220
346
221
In order to succesfully build TensorFlow, your Raspberry Pi needs a little bit more memory to fall back on. Fortunately, this process is pretty straightforward. Grab a USB storage drive that has at least 1GB of memory. I used a flash drive I could live without that carried no important data. That said, we're only going to be using the drive as swap while we compile, so this process shouldn't do too much damage to a relatively new USB drive.
347
222
@@ -402,7 +277,7 @@ sudo nano /etc/fstab
402
277
403
278
Alright! You've got swap! Don't throw out the `/dev/XXX` information yet- you'll need it to remove the device safely later on.
404
279
405
-
### 6. Compiling TensorFlow
280
+
### 5. Compiling TensorFlow
406
281
407
282
First things first, clone the TensorFlow repository and move into the newly created directory.
408
283
@@ -425,7 +300,7 @@ Next, we need to delete a particular line in `tensorflow/core/platform/platform.
425
300
$ sudo nano tensorflow/core/platform/platform.h
426
301
```
427
302
428
-
Now, scroll down toward the bottom and delete the following line containing `#define IS_MOBILE_PLATFORM`:
303
+
Now, scroll down toward the bottom and delete the following line containing `#define IS_MOBILE_PLATFORM` (around line 48):
429
304
430
305
```cpp
431
306
#elif defined(__arm__)
@@ -436,22 +311,26 @@ Now, scroll down toward the bottom and delete the following line containing `#de
436
311
437
312
This keeps our Raspberry Pi device (which has an ARM CPU) from being recognized as a mobile device.
438
313
439
-
Now let's configure Bazel:
314
+
Now let's configure the build:
440
315
441
316
```shell
442
317
$ ./configure
443
318
444
319
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python
445
320
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] N
446
321
Do you wish to build TensorFlow with GPU support? [y/N] N
447
-
```
322
+
Do you wish to build TensorFlow with Hadoop File System support? [y/N] N
323
+
Please input the desired Python library path to use. Default is [/usr/local/lib/python2.7/dist-packages]
324
+
Do you wish to build TensorFlow with OpenCL support? [y/N] N
325
+
Do you wish to build TensorFlow with GPU support? [y/N]
326
+
N```
448
327
449
328
_Note: if you want to build for Python 3, specify `/usr/bin/python3` for Python's location._
450
329
451
330
Now we can use it to build TensorFlow! **Warning: This takes a really, really long time. Several hours.**
_Note: I toyed around with telling Bazel to use all four cores in the Raspberry Pi, but that seemed to make compiling more prone to completely locking up. This process takes a long time regardless, so I'm sticking with the more reliable options here. If you want to be bold, try using `--local_resources 1024,2.0,1.0` or `--local_resources 1024,4.0,1.0`_
There's one last bit of house-cleaning we need to do before we're done: remove the USB drive that we've been using as swap.
474
353
@@ -490,7 +369,7 @@ Then reboot your Raspberry Pi.
490
369
491
370
## References
492
371
493
-
1.[Building TensorFlow for Jetson TK1](http://cudamusing.blogspot.com/2015/11/building-tensorflow-for-jetson-tk1.html)
372
+
1.[Building TensorFlow for Jetson TK1](http://cudamusing.blogspot.com/2015/11/building-tensorflow-for-jetson-tk1.html) (an update to this post is available [here](http://cudamusing.blogspot.com/2016/06/tensorflow-08-on-jetson-tk1.html))
494
373
2.[Turning a USB Drive into swap](http://askubuntu.com/questions/173676/how-to-make-a-usb-stick-swap-disk)
495
374
3.[Safely removing USB swap space](http://askubuntu.com/questions/616437/is-it-safe-to-delete-a-swap-partition-on-a-usb-install)
Copy file name to clipboardexpand all lines: README.md
+10-6
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
# Installing TensorFlow on Raspberry Pi 3 (and probably 2 as well)
2
2
3
+
## Donate
4
+
5
+
If you find the binaries and instructions in this repository useful, [please consider donating to help keep this repository maintained](https://pledgie.com/campaigns/33260). It takes hours of work for each new version of TensorFlow, as well as responding to issues and pull requests.
6
+
3
7
## Intro
4
8
5
9
_We did it!_ It took a lot of head-banging and several indirect passings-of-the-torch, but we finally got TensorFlow compiled and running properly on the Raspberry Pi! Hopefully this will enable more hardware-based machine learning projects, as well as making the distributed aspects of TensorFlow more accessible.
@@ -34,12 +38,12 @@ Next, download the wheel file from this repository and install it:
@@ -57,13 +61,13 @@ _This section will attempt to maintain a list of remedies for problems that may
57
61
This wheel was built with Python 2.7, and can't be installed with a version of `pip` that uses Python 3. If you get the above message, try running the following command instead:
Vice-versa for trying to install the Python 3 wheel. If you get the error "tensorflow-0.11-py3-none-any.whl is not a supported wheel on this platform.", try this command:
0 commit comments