[yocto] Yocto + Cuda + MOOS on NVidia Jetson TK1

Dalton Fury daltonfury42 at gmail.com
Sat Feb 13 12:20:50 PST 2016


I am going to make a yocto build and then install cuda and moos on the
jetson.

At the time of writing of this, kraj's bsp on github is ahead of
cubicool's. Since it did not mention any particular distro, I am going
ahead with YP Core - j
<https://www.yoctoproject.org/downloads/core/fido181>ethro
2.0

So I made a new directory yocto in ~/nava and tried cloning the repo. But
the cloning fails probably because I am behind a firewall. But I am able to
clone it from athena. Someone is blocking the ports. It seems to be working
from mea hostel. So I have freed up some 150 Gigs on my laptop and have
cloned YP Core at /run/media/fury/New\ Volume/yocto/:

git clone -b jrthro git://git.yoctoproject.org/poky.git

Then I cd'ed into the folder and cloned kraj's bsp:

git clone https://github.com/kraj/meta-jetson-tk1.git

I am following the quickstart guide, and I am asked to

source oe-init-build-env


YP requires python 2.X but arch by default uses 3.x. This results is a
error, which is solved by:


https://stackoverflow.com/questions/7237415/python-2-instead-of-python-3-as-the-temporary-default-python

Now that that got taken care of, added

BB_NUMBER_THREADS = "6"
PARALLEL_MAKE = "-j 3"
MACHINE ?= "jetson-tk1-l4t"

to conf/layers.conf

and ran:

bitbake-layers add-layer
"/run/media/fury/storage/yocto/poky/meta-jetson-tk1"

The sanity checker asked me to install a few dependancuies:

sudo pacman -S diffstat chrpath cpio

Day2: The build finished when I let it run throughout the night.

I have created a new repo for my layer in my github account and cloned it.
I am reading the "Project Development Manual" on how to create layers.

Now that I have an empty layer, I proceeded to create a new recipe. I
copied the entire opencv recipe from meta-oe and included the
"-DWITH_CUDA=ON" option.

Since opency requires numerous dependencies and they are all provided in
meta-openembedded, I ended up cloning the meta and then edited its
layer.conf and decreased the priority to 4 so that packages are looked for
in my layer (with priority 5) before looking in that layer

Now that opencv is being compiled in the background, I researched a bit on
cuda. Recalling from a conversation with kraj, I am supposed to use the
correct cuda libraries. This wiki seems to be pointing in the right
direction: http://elinux.org/Jetson/Installing_CUDA

Now, my L4T version is R21.4. So i need to find the binaries for it. Also
it supports cuda 6.5

I got the debs from here:
https://developer.nvidia.com/linux-tegra-r214

(More info here:
https://unix.stackexchange.com/questions/261757/how-to-use-nvidia-cuda-on-poky-yocto-based-linux-os
)

(Make sure you download the *Toolkit for L4T* and not the *Toolkit for
Ubuntu* since that is for cross-compilation instead of native compilation).

So I have examined the .deb. What it does is to create a local file
repository to use with apt. So my plan is to install apt as following the
instructions given here: https://community.freescale.com/thread/325384

Evening: I am in lab, the jetson has booted into yocto. I had to test CUDA
without OpenCV because OpenCV build ran into an error.

I added the following to local.conf:

IMAGE_FEATURES += "package-management"

PACKAGE_CLASSES = "package_deb"

CORE_IMAGE_EXTRA_INSTALL += "\
       git \
       cmake \
       apt \
"

I copied the cuda binaries onto the jetson eMMC and had to create a empty
/var/lib/dpkg/status file before I could continue with the elinux wiki.
(SOLVED A FEW LINE BELOW). All you have to do now is use
--force-architecture option when you use dpkg with cuda debs.

i tried to get apt to work, but it did not. So I went to /var/cuda* and
installed using dpkg -i --force-architecture cuda*

Above command failed for some packages due to dependency issue. So I had to
add

tools-sdk dev-pkgs

to EXTRA_IMAGE_FEATURES in local.conf

I tried commenting out all entries in opencv which has to do with java, and
will know if it worked any time now...

WoW both independently worked!

Added gnupg in attempt to fix apt.... did not work...

Opencv had some trouble linking with static libs, and I had to add this
line to local.conf:

IMAGE_INSTALL_append = "opencv-staticdev"

Testing if that did the job... worked

After a lot of trys, I cude get an opencv code with cuda to link.

I had to add NOTHING to cmakelists.txt and include
#include<opencv2/core/cuda.cpp> to the cpp file.

The GPU count came out to be 0. :-(

It has to be smething with the cmake compilation. I am thinking of writing
a new recipe on my own.

I've made a simple recipe which just compiled opencv with cuda. See
commit 8f511945d3d989ab22399d1898d1d92de3abb312 on git.

It did compile but had packaging issues. Also in do_configure logs i found
that Use CUDA: NO as cmake output. I had a chat with comeone in cmake irc,
and he is confident that I have to install cuda before installing opencv or
cuda functions will fail at runtime even if cuda was installed at runtime.

So here is what I am going to do. I am doing to write recipes to install
each of the debs.

It is going well. Gotta fix dependencies. Not completely fixed, everything
get's installed when i install cuda-toolkit-6-5

But still opencv is not compiling with cuda. Fpr some reason all the
binaries are not installed. Let them solve it for me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20160214/a32d5d07/attachment.html>


More information about the yocto mailing list