Setup the environment

Hello everyone!

I am a newbie in CUDA.
For my bachelor thesis, I have to implement some imageprocessing algorithms. I have setup the Jetson TK1 and installed the Developerkit on my Laptop. The cuda samples are running and I am able to compile and run a simple helloworld in terminal. I have tried to use Nsight but the crosscompilation doesnt work. My supervisor told my, it’s easier to compile on the board. But I have no idea how to create a Makefile.

So I need help to compile my first programm.
Is it possible to create a Makefile with Cmake?
Or can anyone help my to setup the crosscompilation?

Thanks

Not an answer, but realize that the Jetson is a full Linux development environment which needs extra packages installed to do more than basics. “cmake” is one such package which can be installed and which does not arrive installed by default (not everyone uses it, and an embedded environment does not typically install every option that a desktop would).

First, downloads typically come from repositories listed in the Jetson’s file “/etc/apt/sources.list”. Some of those are commented out, and only packages active from sources.list are shown when working with the “apt” or “apt-get” tools for packages (the cuda repo package adds the cuda repository, not cuda itself). The command “sudo apt update” marks a list of files from repositories, typically you’d run “sudo apt update” before any upgrade or install commands, especially if you just uncommented something in sources.list.

You’d probably want to make sure existing packages are up to date:

sudo apt update
sudo apt-get upgrade

You might want to verify nVidia-specific files are still in place (this hasn’t been an issue since R19.2):

sha1sum -c /etc/nv_tegra_release

Then you’d search for your package:

apt search cmake

You would see related packages. You might install these:

sudo apt-get install cmake cmake-curses-gui cmake-doc

(usually docs are installed in both man pages and a “/usr/share/doc/” subdirectory. You could skip cmake-doc and use docs from your laptop computer)

Then try nsight eclipse again, perhaps you just needed cmake installed at the Jetson. Even if you develop natively on Jetson, you’d still need cmake package. If the software compiled on the laptop, then it should already have any kind of configuration file for cmake to be copied over to Jetson the same way as it was copied to your laptop.

Hello linuxdev and thank you for your answer.
I have some experiences with Linux and the package manager.
I have followed your instrctions but for shalsum I got: command not found.
Cmake is installed.

I tried to follow this blog:
https://devblogs.nvidia.com/parallelforall/nvidia-nsight-eclipse-edition-for-jetson-tk1/

Should I run all these commands on my laptop?
On the 2nd step I got an error:

user@laptop:~$ sudo dpkg – i cuda-repo-ubuntu1204_6.0-37_amd64.deb
Unknown configuration key `foreign-architecture' found in your `dpkg'
configuration files.  This warning will become a hard error at a later
date, so please remove the offending configuration options and replace
them with `dpkg --add-architecture' invocations at the command line.

Unknown configuration key `foreign-architecture' found in your `dpkg'
configuration files.  This warning will become a hard error at a later
date, so please remove the offending configuration options and replace
them with `dpkg --add-architecture' invocations at the command line.

dpkg: Fehler: eine Aktions-Option wird benötigt

Nutzen Sie dpkg --help für Hilfe zur Installation und Deinst. von Paketen [*];
Benutzen Sie »apt« oder »aptitude« für benutzerfreundliches Paketmanagement;
Nutzen Sie dpkg -Dhelp für eine Liste von Debug-Flags von dpkg;
Nutzen Sie dpkg --force-help für eine Liste von Optionen zum Erzwingen;
Nutzen Sie dpkg-deb --help für Hilfe zum Manipulieren von *.deb-Dateien;

Optionen mit [*] geben viel aus - schicken Sie es durch »less« oder »more«!

The 3rd step also dont work.

For the Projektproperties in Nsight:
Which CPU architecture has the TK1?
And which architecture should I choose for my local system (Lenovo N581)?

Thank you for your answers.

I’ve heard of bugs before related to non-default language locales…meaning other than en_US. I see your locale is not en_US, so I’m suddenly suspicious if there is a locale bug with packages.

FYI, “sha1sum” should exist by default in all of the L4T releases (intended to run from Jetson, but the sha1sum command exists in all Linux desktop distributions as well). The file named as an argument here will exist only after installing the nVidia-specific files on a Jetson:

sha1sum -c /etc/nv_tegra_release

I am not fluent in any other human languages (I can eventually figure out Latin or French with some research), so I don’t know what the errors are. The packages added to the Jetson itself though should not require foreign architecture, only cross-compile tools on the x86_64 host would require this.

The JTK1 architecture is ARMv7, sometimes just shortened to “arm” (if this were a TX1 it’d be “ARMv8a” shortened to “arm64” or “aarch64”). Your standard desktop and laptop machines are x86_64. Older desktop/laptop versions would also have “86” in the name, e.g., i686.

Thank you for the hint. I will search for informations about that bug.

Now I have tried this:


sounds easier because not all Libraries are needed on the Host but I dont know how to config in Nsight, that the TK1 should compile the code.

I dont have installed cuda new, but I have installed and configured git.

I have tried to load and run the particle sample without success.
I have documented each step with an screenshot and create the pdf in the attachment.
There are also questions in that file.

I hope you can answer them and maybe see, what I did wrong.

Thanks for your help!

Documentation.pdf (321 KB)

My host is Fedora, and JetPack requires Ubuntu 14.04, so it is something I can’t help with. I would definitely try to figure out first why the “sha1sum -c /etc/nv_tegra_release” fails on the Jetson…if this fails almost nothing with CUDA would work correctly. Not having sha1sum indicates a serious install failure on the Jetson which could interfere with other software installs as well.

In the case of repo packages such as “cuda-repo-ubuntu1204_6.0-37_amd64.deb”, this is run on the Jetson TK1 if armhf, Jetson TX1 if arm64, but run on host if amd64. These packages essentially point the Linux system to compatible CUDA repositories.

Using nsight eclipse from a separate host may be nice, but it drastically complicates things (especially if your goal is to build for Jetson and do not care if the same code runs on the host PC). Not all CUDA samples will run on a Jetson, I’m not sure if the one you’re looking at is one or not. What you can be sure of is that if you cannot build and run a sample natively within the Jetson, that nsight eclipse will also fail. It is good to test native command line build first.

sha1sum -c /etc/nv_tegra_release

now works. OK after each line.
The particles example really dont work on my TK1. I have choosen now an other example oceanFFT which runs when compiling on the TK1 in terminal, but with the same problems. Also dont work with Nsight on the Host.

How do you compile your programs?

I do a native compile in every case where I can. Any software I create uses a regular makefile.

I do not use any IDE, I typically use vi or a nicer editor such as kate. I’ve experimented with NFS mounts to aid host PC editing directly, but found that because I do things with the kernel NFS is a very bad idea (suppose you stop the kernel with kgdboc while debugging the kernel…NFS also stops…or if you trigger a kernel OOPS…NFS stops).

My Problem with the CUDA Samples is that the makefiles are to complicate for me.
I have now tried to create a makefile for the Sample OceanFFT with Cmake.
http://bikulov.org/blog/2013/12/24/example-of-cmake-file-for-cuda-plus-cpp-code/

I added lines to include some libraries and changed the path in the last line.
But I am not sure if I did this correctly.

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(lbmslv)

FIND_PACKAGE(CUDA REQUIRED)
FIND_PACKAGE(MPI REQUIRED)
FIND_PACKAGE(OpenGL REQUIRED)

INCLUDE(FindCUDA)

INCLUDE_DIRECTORIES(/usr/local/cuda/include ${MPI_INCLUDE_PATH})
INCLUDE_DIRECTORIES(/usr/local/cuda-6.5/samples/common/inc ${SAMPLELIB_INCLUDE_PATH})
INCLUDE_DIRECTORIES(/usr/local/cuda-6.5/samples/common/lib/linux/armv7l  ${GLEW_INCLUDE_PATH})

FILE(GLOB SOURCES "*.cu" "*.cpp" "*.c" "*.h")
CUDA_ADD_EXECUTABLE(lbmslv ${SOURCES})

LIST(APPEND CMAKE_CXX_FLAGS "-std=c++0x -O3 -ffast-math -Wall")

LIST(APPEND CUDA_NVCC_FLAGS --compiler-options -fno-strict-aliasing -lineinfo -use_fast_math -Xptxas -dlcm=cg)
LIST(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_20,code=sm_20)
LIST(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_30,code=sm_30)
LIST(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_35,code=sm_35)

TARGET_LINK_LIBRARIES(lbmslv /usr/local/cuda/lib/libcudart.so ${MPI_LIBRARIES})

When I now run make, I get a lot errors.
No reference to … ( glut… , gl… and glew… functions. )

Hope, you can tell me what I did wrong.
Thank you!

It sounds like you need the headers to common graphics libraries. These are the development (“dev”) versions of the libraries which add the headers and not just the libararies. You can use “apt search something” to search for packages related to something mentioned in the missing file list, and then install the dev version. If the files are already there, then it just means you didn’t point the compiler at the right directory (or something equivalent to a missing file).