├── LICENSE ├── README.md ├── installCaffe.sh ├── installCaffeCuDNN.sh └── jetson_clocks.sh /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2016 Jetsonhacks 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # installCaffeJTX1 2 | Scripts to install Caffe and dependencies on the NVIDIA Jetson TX1 Development Kit. 3 | This script is for L4T 24.2 (Ubuntu 16.04). Look in 'Tags' for earlier versions. 4 | 5 | To install, run the installCaffe.sh script 6 | $ ./installCaffe.sh 7 | 8 | To maximize the performance of the Jetson TX1, you can use the jetson_clocks.sh script which enables all CPU cores, and maximizes clock speeds on the CPUs and GPU. 9 | 10 | For best results, on the Jetson TX1 you should have installed: 11 | 12 | L4T 24.2 (Ubuntu 16.04) 13 | OpenCV4Tegra 14 | CUDA 8.0 15 | cuDNN v5.1 16 | 17 | Last tested with last Github Caffe commit: 80f44100e19fd371ff55beb3ec2ad5919fb6ac43 18 | 19 | -------------------------------------------------------------------------------- /installCaffe.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script for installing Caffe support on Jetson TX1 Development Kitls 3 | # 9-15-16 JetsonHacks.com 4 | # MIT License 5 | # Install and compile Caffe on NVIDIA Jetson TX1 Development Kit 6 | # Prerequisites (which can be installed with JetPack 2): 7 | # L4T 24.2 (Ubuntu 16.04) 8 | # OpenCV4Tegra 9 | # CUDA 8.0 10 | # cuDNN v5.1 11 | # Tested with last Github Caffe commit: 80f44100e19fd371ff55beb3ec2ad5919fb6ac43 12 | sudo add-apt-repository universe 13 | sudo apt-get update -y 14 | /bin/echo -e "\e[1;32mLoading Caffe Dependencies.\e[0m" 15 | sudo apt-get install cmake -y 16 | # General Dependencies 17 | sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev \ 18 | libhdf5-serial-dev protobuf-compiler -y 19 | sudo apt-get install --no-install-recommends libboost-all-dev -y 20 | # BLAS 21 | sudo apt-get install libatlas-base-dev -y 22 | # Remaining Dependencies 23 | sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev -y 24 | sudo apt-get install python-dev python-numpy -y 25 | 26 | sudo usermod -a -G video $USER 27 | /bin/echo -e "\e[1;32mCloning Caffe into the home directory\e[0m" 28 | # Place caffe in the home directory 29 | cd $HOME 30 | # Git clone Caffe 31 | git clone https://github.com/BVLC/caffe.git 32 | cd caffe 33 | cp Makefile.config.example Makefile.config 34 | # Regen the makefile; On 16.04, aarch64 has issues with a static cuda runtime 35 | cmake -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF 36 | # Include the hdf5 directory for the includes; 16.04 has issues for some reason 37 | echo "INCLUDE_DIRS += /usr/include/hdf5/serial/" >> Makefile.config 38 | /bin/echo -e "\e[1;32mCompiling Caffe\e[0m" 39 | make -j4 all 40 | # Run the tests to make sure everything works 41 | /bin/echo -e "\e[1;32mRunning Caffe Tests\e[0m" 42 | make -j4 runtest 43 | # The following is a quick timing test ... 44 | # tools/caffe time --model=models/bvlc_alexnet/deploy.prototxt --gpu=0 45 | -------------------------------------------------------------------------------- /installCaffeCuDNN.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script for installing Caffe with cuDNN support on Jetson TX1 Development Kitls 3 | # 9-15-16 JetsonHacks.com 4 | # MIT License 5 | # Install and compile Caffe on NVIDIA Jetson TX1 Development Kit 6 | # Prerequisites (which can be installed with JetPack 2): 7 | # L4T 24.2 (Ubuntu 16.04) 8 | # OpenCV4Tegra 9 | # CUDA 8.0 10 | # cuDNN v5.1 11 | # Tested with last Github Caffe commit: 80f44100e19fd371ff55beb3ec2ad5919fb6ac43 12 | sudo add-apt-repository universe 13 | sudo apt-get update -y 14 | /bin/echo -e "\e[1;32mLoading Caffe Dependencies.\e[0m" 15 | sudo apt-get install cmake -y 16 | # General Dependencies 17 | sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev \ 18 | libhdf5-serial-dev protobuf-compiler -y 19 | sudo apt-get install --no-install-recommends libboost-all-dev -y 20 | # BLAS 21 | sudo apt-get install libatlas-base-dev -y 22 | # Remaining Dependencies 23 | sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev -y 24 | sudo apt-get install python-dev python-numpy -y 25 | 26 | sudo usermod -a -G video $USER 27 | /bin/echo -e "\e[1;32mCloning Caffe into the home directory\e[0m" 28 | # Place caffe in the home directory 29 | cd $HOME 30 | # Git clone Caffe 31 | git clone https://github.com/BVLC/caffe.git 32 | cd caffe 33 | cp Makefile.config.example Makefile.config 34 | # Enable cuDNN usage 35 | sed -i 's/# USE_CUDNN/USE_CUDNN/g' Makefile.config 36 | # Regen the makefile; On 16.04, aarch64 has issues with a static cuda runtime 37 | cmake -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF 38 | # Include the hdf5 directory for the includes; 16.04 has issues for some reason 39 | echo "INCLUDE_DIRS += /usr/include/hdf5/serial/" >> Makefile.config 40 | /bin/echo -e "\e[1;32mCompiling Caffe\e[0m" 41 | make -j4 all 42 | # Run the tests to make sure everything works 43 | /bin/echo -e "\e[1;32mRunning Caffe Tests\e[0m" 44 | make -j4 runtest 45 | # The following is a quick timing test ... 46 | # tools/caffe time --model=models/bvlc_alexnet/deploy.prototxt --gpu=0 47 | -------------------------------------------------------------------------------- /jetson_clocks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions 6 | # are met: 7 | # * Redistributions of source code must retain the above copyright 8 | # notice, this list of conditions and the following disclaimer. 9 | # * Redistributions in binary form must reproduce the above copyright 10 | # notice, this list of conditions and the following disclaimer in the 11 | # documentation and/or other materials provided with the distribution. 12 | # * Neither the name of NVIDIA CORPORATION nor the names of its 13 | # contributors may be used to endorse or promote products derived 14 | # from this software without specific prior written permission. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 17 | # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 | # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | CONF_FILE=${HOME}/l4t_dfs.conf 29 | RED='\e[0;31m' 30 | GREEN='\e[0;32m' 31 | BLUE='\e[0;34m' 32 | BRED='\e[1;31m' 33 | BGREEN='\e[1;32m' 34 | BBLUE='\e[1;34m' 35 | NC='\e[0m' # No Color 36 | 37 | usage() 38 | { 39 | if [ "$1" != "" ]; then 40 | echo -e ${RED}"$1"${NC} 41 | fi 42 | 43 | echo "usage:" 44 | 45 | cat >& 2 < $file 66 | fi 67 | ;; 68 | *) 69 | echo $data > $file 70 | ret=$? 71 | if [ ${ret} -ne 0 ]; then 72 | echo "Error: Failed to restore $file" 73 | fi 74 | ;; 75 | esac 76 | done 77 | } 78 | 79 | store() 80 | { 81 | for file in $@; do 82 | if [ -e "${file}" ]; then 83 | echo "$file:`cat $file`" >> $CONF_FILE 84 | fi 85 | done 86 | } 87 | 88 | do_fan() 89 | { 90 | # Jetson-TK1 CPU fan is always ON. 91 | if [ -e /sys/devices/soc0/machine ]; then 92 | machine=`cat /sys/devices/soc0/machine` 93 | if [ "${machine}" = "jetson-tk1" ] ; then 94 | return 95 | fi 96 | fi 97 | 98 | if [ ! -w /sys/kernel/debug/tegra_fan/target_pwm ]; then 99 | echo "Can't access Fan!" 100 | return 101 | fi 102 | 103 | case $ACTION in 104 | show) 105 | echo "Fan: speed=`cat /sys/kernel/debug/tegra_fan/target_pwm`" 106 | ;; 107 | store) 108 | store /sys/kernel/debug/tegra_fan/target_pwm 109 | ;; 110 | *) 111 | FAN_SPEED=255 112 | echo $FAN_SPEED > /sys/kernel/debug/tegra_fan/target_pwm 113 | ;; 114 | esac 115 | } 116 | 117 | do_clusterswitch() 118 | { 119 | case $ACTION in 120 | show) 121 | if [ -d /sys/kernel/cluster ]; then 122 | ACTIVE_CLUSTER=`cat /sys/kernel/cluster/active` 123 | echo "CPU Cluster Switching: Active Cluster ${ACTIVE_CLUSTER}" 124 | else 125 | echo "CPU Cluster Switching: Disabled" 126 | fi 127 | ;; 128 | store) 129 | if [ -d /sys/kernel/cluster ]; then 130 | store "/sys/kernel/cluster/immediate" 131 | store "/sys/kernel/cluster/force" 132 | store "/sys/kernel/cluster/active" 133 | fi 134 | ;; 135 | *) 136 | if [ -d /sys/kernel/cluster ]; then 137 | echo 1 > /sys/kernel/cluster/immediate 138 | echo 0 > /sys/kernel/cluster/force 139 | echo G > /sys/kernel/cluster/active 140 | fi 141 | ;; 142 | esac 143 | } 144 | 145 | do_hotplug() 146 | { 147 | CPU_HOTPLUG_STAT=`cat /sys/devices/system/cpu/cpuquiet/tegra_cpuquiet/enable` 148 | 149 | case $ACTION in 150 | show) 151 | echo "CPU HOTPLUG: $CPU_HOTPLUG_STAT" 152 | echo "Online CPUs: `cat /sys/devices/system/cpu/online`" 153 | for folder in /sys/devices/system/cpu/cpu[0-9]; do 154 | if [ -e "${folder}/cpufreq/scaling_cur_freq" ]; then 155 | CPU=`echo ${folder} | cut -c 25-` 156 | echo "$CPU: `cat ${folder}/cpufreq/scaling_cur_freq`" 157 | fi 158 | done 159 | ;; 160 | store) 161 | store "/sys/devices/system/cpu/cpuquiet/tegra_cpuquiet/enable" 162 | for file in /sys/devices/system/cpu/cpu*/online; do 163 | store $file 164 | done 165 | ;; 166 | *) 167 | echo 0 > /sys/devices/system/cpu/cpuquiet/tegra_cpuquiet/enable 168 | for file in /sys/devices/system/cpu/cpu*/online; do 169 | if [ `cat $file` -eq 0 ]; then 170 | echo 1 > $file 171 | fi 172 | done 173 | esac 174 | } 175 | 176 | do_cpu() 177 | { 178 | FRQ_GOVERNOR=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor` 179 | CPU_MIN_FREQ=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq` 180 | CPU_MAX_FREQ=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq` 181 | CPU_CUR_FREQ=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` 182 | 183 | case $ACTION in 184 | show) 185 | echo "CPU frequency Governor: $FRQ_GOVERNOR" 186 | echo "CPU MinFreq=$CPU_MIN_FREQ MaxFreq=$CPU_MAX_FREQ CurrentFreq=$CPU_CUR_FREQ" 187 | ;; 188 | store) 189 | store "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" 190 | 191 | if [ -d /sys/devices/system/cpu/cpufreq/$FRQ_GOVERNOR ]; then 192 | store `find /sys/devices/system/cpu/cpufreq/$FRQ_GOVERNOR -type f -perm -g+r` 193 | fi 194 | ;; 195 | *) 196 | echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 197 | echo $CPU_MAX_FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed 198 | ;; 199 | esac 200 | } 201 | 202 | do_gpu() 203 | { 204 | GPU_MIN_FREQ=`cat /sys/kernel/debug/clock/override.gbus/min` 205 | GPU_MAX_FREQ=`cat /sys/kernel/debug/clock/override.gbus/max` 206 | GPU_CUR_FREQ=`cat /sys/kernel/debug/clock/override.gbus/rate` 207 | GPU_FREQ_OVERRIDE=`cat /sys/kernel/debug/clock/override.gbus/state` 208 | 209 | case $ACTION in 210 | show) 211 | echo "GPU MinFreq=$GPU_MIN_FREQ MaxFreq=$GPU_MAX_FREQ CurrentFreq=$GPU_CUR_FREQ FreqOverride=$GPU_FREQ_OVERRIDE" 212 | ;; 213 | store) 214 | store /sys/kernel/debug/clock/override.gbus/rate 215 | store /sys/kernel/debug/clock/override.gbus/state 216 | ;; 217 | *) 218 | echo $GPU_MAX_FREQ > /sys/kernel/debug/clock/override.gbus/rate 219 | echo 1 > /sys/kernel/debug/clock/override.gbus/state 220 | ret=$? 221 | if [ ${ret} -ne 0 ]; then 222 | echo "Error: Failed to max GPU frequency!" 223 | fi 224 | ;; 225 | esac 226 | } 227 | 228 | do_emc() 229 | { 230 | EMC_MIN_FREQ=`cat /sys/kernel/debug/clock/override.emc/min` 231 | EMC_MAX_FREQ=`cat /sys/kernel/debug/clock/override.emc/max` 232 | EMC_CUR_FREQ=`cat /sys/kernel/debug/clock/override.emc/rate` 233 | EMC_FREQ_OVERRIDE=`cat /sys/kernel/debug/clock/override.emc/state` 234 | 235 | case $ACTION in 236 | show) 237 | echo "EMC MinFreq=$EMC_MIN_FREQ MaxFreq=$EMC_MAX_FREQ CurrentFreq=$EMC_CUR_FREQ FreqOverride=$EMC_FREQ_OVERRIDE" 238 | ;; 239 | store) 240 | store /sys/kernel/debug/clock/override.emc/rate 241 | store /sys/kernel/debug/clock/override.emc/state 242 | ;; 243 | *) 244 | echo $EMC_MAX_FREQ > /sys/kernel/debug/clock/override.emc/rate 245 | echo 1 > /sys/kernel/debug/clock/override.emc/state 246 | ;; 247 | esac 248 | } 249 | 250 | check_uptime() 251 | { 252 | 253 | if [ -e "/proc/uptime" ]; then 254 | uptime=`cat /proc/uptime | cut -d '.' -f1` 255 | 256 | if [ $((uptime)) -lt 90 ]; then 257 | printf "Error: Please run the script after $((90 - uptime)) Seconds, \ 258 | \notherwise ubuntu init script may override the clock settings!\n" 259 | exit -1 260 | fi 261 | else 262 | printf "Warning: Could not check system uptime. Please make sure that you run the script 90 Seconds after bootup, \ 263 | \notherwise ubuntu init script may override the clock settings!\n" 264 | fi 265 | } 266 | 267 | main () 268 | { 269 | check_uptime 270 | while [ -n "$1" ]; do 271 | case "$1" in 272 | --show) 273 | ACTION=show 274 | ;; 275 | --store) 276 | [ -n "$2" ] && CONF_FILE=$2 277 | ACTION=store 278 | shift 1 279 | ;; 280 | --restore) 281 | [ -n "$2" ] && CONF_FILE=$2 282 | ACTION=restore 283 | shift 1 284 | ;; 285 | -h|--help) 286 | usage 287 | exit 0 288 | ;; 289 | *) 290 | usage "Unknown option: $1" 291 | exit 1 292 | ;; 293 | esac 294 | shift 1 295 | done 296 | 297 | [ `whoami` != root ] && echo Error: Run this script\($0\) as a root user && exit 1 298 | 299 | case $ACTION in 300 | store) 301 | if [ -e "${CONF_FILE}" ]; then 302 | echo "File $CONF_FILE already exists. Can I overwrite it? Y/N:" 303 | read answer 304 | case $answer in 305 | y|Y) 306 | rm -f $CONF_FILE 307 | ;; 308 | *) 309 | echo "Error: file $CONF_FILE already exists!" 310 | exit 1 311 | ;; 312 | esac 313 | fi 314 | ;; 315 | restore) 316 | if [ ! -e "${CONF_FILE}" ]; then 317 | echo "Error: $CONF_FILE file not found !" 318 | exit 1 319 | fi 320 | restore 321 | exit 0 322 | ;; 323 | esac 324 | 325 | do_cpu 326 | do_hotplug 327 | do_clusterswitch 328 | do_gpu 329 | do_emc 330 | do_fan 331 | } 332 | 333 | main $@ 334 | exit 0 335 | --------------------------------------------------------------------------------