How to port OpenCv to NaCl - google-chrome

Does anyone know any way how to port OpenCV to NaCl? I'm trying to make Chrome extension based on face recognition. I would appreciate some help.

The detailed instructions below have been reposted from (the now defunct metacaptcha.com/install_opencv_nacl) for convenience.
1. Prerequitsites
OpenCV depends on several important libraries such as bzip2, zlib, NaclMounts and at least one decompression/compression library to handle common images such as libpng/jpeg/tiff. This article will focus on libjpeg only. Those libraries need to be built in both 32-bit and 64-bit architect as dynamic library using NaCl Glibc toolchain (Pepper 28).
In order to build the 32-bit and 64-bit shared libraries for NaCl, the 32-bit and 64-bit version of NaCl gcc/linker need to be used respectively. To make this easier in the tutorial, we make the following environment variables:
Note: In case one of the link in the article failed to work, a backup link can be found here.
export NACL_SDK_ROOT=/Users/thai/apps/nacl_sdk/pepper_28
export NACL_PREFIX="$NACL_SDK_ROOT"/toolchain/mac_x86_glibc/x86_64-nacl
export NACL_64="$NACL_SDK_ROOT"/toolchain/mac_x86_glibc/bin/x86_64-nacl
export NACL_32="$NACL_SDK_ROOT"/toolchain/mac_x86_glibc/bin/i686-nacl
1.1 Bzip2 for Native Client
Download Bzip2 v1.0.6, extract to your local directory. Makefile-libbz2_so is the file we want to use for make, we want to change the gcc toolchain parameters such that, instead of using the regular OS gcc, it will use the NaCl gcc in $NACL_SDK_ROOT/toolchain/mac_x86_glibc/x86_64-nacl/bin/.
Run make -f Makefile-libbz2_so on bzip2 with the following parameters, then copy the library into NaCl toolchain.
make -f Makefile-libbz2_so CC=$NACL_64-'gcc -m64'
cp libbz2.so.1.0.6 $NACL_PREFIX/lib64/libbz2.so
make clean
make -f Makefile-libbz2_so CC=$NACL_32-'gcc -m32'
cp libbz2.so.1.0.6 $NACL_PREFIX/lib32/libbz2.so
cp *.h $NACL_PREFIX/include
1.2 Zlib for Native Client
Download Zlib-1.2.8, extract to your local directory. Zlib is using autoconfig to generate Makefile, we will need to run this tool first then modify the GCC toolchain into NaCl one.
Run ./configure --enable-shared on zlib, then run make with the following parameters.
./configure --enable-shared
make shared CC=$NACL_64-'gcc -m64' AR=$NACL_64-ar ARFLAGS=rc CFLAGS='-O3 -DHAVE_HIDDEN' LDFLAGS='-O3 -fPIC -DHAVE_HIDDEN' LDSHARED='$(CC) -shared -Wl,-soname -Wl,libz.so' SHAREDLIB=libz.so SHAREDLIBM=libz.so.1.2.8 SHAREDLIBV=libz.so.1
cp libz.so.1 $NACL_PREFIX/lib64/libz.so
make clean
make shared CC=$NACL_32-'gcc -m32' AR=$NACL_32-ar ARFLAGS=rc CFLAGS='-O3 -DHAVE_HIDDEN' LDFLAGS='-O3 -fPIC -DHAVE_HIDDEN' LDSHARED='$(CC) -shared -Wl,-soname -Wl,libz.so' SHAREDLIB=libz.so SHAREDLIBM=libz.so.1.2.8 SHAREDLIBV=libz.so.1
cp libz.so.1 $NACL_PREFIX/lib32/libz.so
cp zlib.h zconf.h $NACL_PREFIX/include
1.3 libJPEG for Native Client
Download jpeg-v6b, NaCl jpeg makefile.cfg patch and put them to your local directory.
Patch the jpeg-v6b directory with the nacl-jpeg-makefile.cfg patch.
cd jpeg-6b
patch < nacl-jpeg-v6b-makefile.cfg.patch
Run ./configure on jpeg-6b, then run make libjpeg.so with the following parameters.
./configure
make libjpeg.so CC=$NACL_64-gcc CFLAGS='-m64 -fPIC -O2 -I.' LDFLAGS='-shared -Wl,-soname -Wl,libjpeg.so -o libjpeg.so'
mv libjpeg.so $NACL_PREFIX/lib64/libjpeg.so
make clean
make libjpeg.so CC=$NACL_32-gcc CFLAGS='-m32 -fPIC -O2 -I.' LDFLAGS='-shared -Wl,-soname -Wl,libjpeg.so -o libjpeg.so'
mv libjpeg.so $NACL_PREFIX/lib32/libjpeg.so
make install-headers prefix=$NACL_PREFIX
1.4 NaclMounts for Native Client
Download NaclMounts, nacl-mounts.patch and our custom Makefile
Go to your local nacl-mount directory, copy the Makefile into this directory, applying the patch and run the following commands (assuming you already set the environment variables at the beginning of the article)
cp Makefile nacl-mounts/
cd nacl-mounts/
patch -p0 < ../nacl-mounts.patch
make ARCH=x86_64 BIT=64
cp libnaclmounts.so $NACL_PREFIX/lib64
make clean
make ARCH=i686 BIT=32
cp libnaclmounts.so $NACL_PREFIX/lib32
make install-headers
2. OpenCV for Native Client
OpenCV need to be built in cross-compiling mode, to easily do that with cmake (build tool of OpenCV). We set CMAKE_SYSTEM_NAME=Linux to force cross-compiling for Linux target. A OpenCV-nacl-cmake script is written in order to facilitate the build process if you have already setup the environment variables in the previous step.
2.1 Setup source code
Download OpenCV 2.4.2, opencv-nacl-cmake script
Extract OpenCV to your local directory.
Create nacl/m32, nacl/m64 directory in OpenCV-2.4.2/ for building 32/64 bit version of OpenCV Native Client code.
Copy opencv-nacl-cmake script into nacl/ directory.
tar xvf OpenCV-2.4.2.tar.gz
cd OpenCV-2.4.2
mkdir nacl
cd nacl
mkdir m64 m32
cp ~/Downloads/opencv-nacl-cmake ./
2.2 Patch OpenCV I/O Library (persistance.cpp) / Exclude building of apps
In order for OpenCV to read/write to files in Native Client, a new file system library need to be used. This patch replace all the OS system calls for file I/O with NaclMounts library.
Download persistance.cpp patch for OpenCV 2.4.2
Copy the patch to your OpenCV dir, and apply the path using these commands
cp ~/Download/opencv-nacl-persistance.patch OpenCV-2.4.2
cd OpenCV-2.4.2
patch -p0 < opencv-nacl-persistance.patch
We also need to tell cmake to exclude the apps module in OpenCV (the apps module doesn't need to be ported). This can be done by simply moving the CMakeList.txt file in apps directory
mv apps/CMakeList.txt apps/CMakeList.txt.old
2.3 Configure, build and install
Run ./opencv-nacl-cmake with the following parameters to configure and build the library. The following bash commands also install both 32 and 64-bit versions of the library for OpenCV. Because of the naming convention of Native Client, we have to move the lib/, lib32/, lib64/ directory around in order to install the architecture correctly.
cd nacl/m32
../opencv-nacl-cmake i686 32
make -j8
unlink $NACL_PREFIX/lib64
mv $NACL_PREFIX/lib $NACL_PREFIX/lib64
mv $NACL_PREFIX/lib32 $NACL_PREFIX/lib
ln -s $NACL_PREFIX/lib $NACL_PREFIX/lib32
make install
unlink $NACL_PREFIX/lib32
mv $NACL_PREFIX/lib $NACL_PREFIX/lib32
mv $NACL_PREFIX/lib64 $NACL_PREFIX/lib
ln -s $NACL_PREFIX/lib $NACL_PREFIX/lib64
cd ../m64
../opencv-nacl-cmake x86_64 64
make -j8
make install
At this point, you have finished installing OpenCV 2.4.2 for Native Client Pepper 28.
A simple applications adapted from the OpenCV's tutorials to perform face detection in Google Chrome can be found in example_opencv_nacl_facedetect.

Related

Install Cuda without root

I know that I can install Cuda with the following:
wget http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run
chmod +x cuda_7.0.28_linux.run
./cuda_7.0.28_linux.run -extract=`pwd`/nvidia_installers
cd nvidia_installers
sudo ./NVIDIA-Linux-x86_64-346.46.run
sudo modprobe nvidia
sudo ./cuda-linux64-rel-7.0.28-19326674.run
Just wondering if I can install Cuda without root?
Thanks,
Update The installation UI for 10.1 changed. The following works:
Deselect driver installation (pressing ENTERon it)
Change options -> root install path to a non-sudo directory.
Press A on the line marked with a + to access advanced options. Deselect create symbolic link, and change the toolkit install path.
Now installation should work without root permissions
Thank you very much for the hints in the question! I just want to complete it with an approach that worked for me, also inspired in this gist and that hopefully helps in situations where a valid driver is installed, and installing a more recent CUDA on Linux without root permissions is still needed.
TL;DR: Here are the steps to install CUDA9+CUDNN7 on Debian, and installing a pre-compiled version of TensorFlow1.4 on Python2.7 to test that everything works. Everything without root privileges and via terminal. Should also work for other CUDA, CUDNN, TensorFlow and Python versions on other Linux systems too.
INSTALLATION
Go to NVIDIA's official release web for CUDA (as for Nov. 2017, CUDA9 is out): https://developer.nvidia.com/cuda-downloads.
Under your Linux distro, select the runfile (local)option. Note that the sudo indication present in the installation instructions is deceiving, since it is possible to run this installer without root permissions. On a server, one easy way is to copy the <LINK> of the Download button and, in any location of your home directory, run wget <LINK>. It will download the <INSTALLER> file.
Run chmod +x <INSTALLER> to make it executable, and execute it ./<INSTALLER>.
accept the EULA, say no to driver installation, and enter a <CUDA> location under your home directory to install the toolkit and a <CUDASAMPLES> for the samples.
Not asked here but recommended: Download a compatible CUDNN file from the official web (you need to sign in). In my case, I downloaded the cudnn-9.0-linux-x64-v7.tgz, compatible with CUDA9 into the <CUDNN> folder. Uncompress it: tar -xzvf ....
Optional: compile the samples. cd <CUDASAMPLES> && make. There are some very nice examples there and a very good starting point to write some CUDA scripts of yourself.
(If you did 5.): Copy the required files from <CUDNN> into <CUDA>, and grant reading permission to user (not sure if needed):
cp -P <CUDNN>/cuda/include/cudnn.h <CUDA>/include/
cp -P <CUDNN>/cuda/lib64/libcudnn* <CUDA>/lib64
chmod a+r <CUDA>/include/cudnn.h <CUDA>/lib64/libcudnn*
Add the library to your environment. This is typically done adding this following two lines to your ~/.bashrc file (in this example, the <CUDA> directory was ~/cuda9/:
export PATH=<CUDA>/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<CUDA>/lib64/
FOR QUICK TESTING OR TENSORFLOW USERS
The quickest way to get a TensorFlow compatible with CUDA9 and CUDNN7 (and a very quick way to test this) is to download a precompiled wheel file and install it with pip install <WHEEL>. Most of the versions you need, can be found in mind's repo (thanks a lot guys). A minimal test that confirms that CUDNN is also working involves the use of tf.nn.conv2d:
import tensorflow as tf
x = tf.nn.conv2d(tf.ones([1,1,10,1]), tf.ones([1,5,1,1]), strides=[1, 1, 1, 1], padding='SAME')
with tf.Session() as sess:
sess.run(x) # this should output a tensor of shape (1,1,10,1) with [3,4,5,5,5,5,5,5,4,3]
In my case, the wheel I installed required Intel's MKL library, as explained here. Again, from terminal and without root users, this are the steps I followed to install the library and make TensorFlow find it (reference):
git clone https://github.com/01org/mkl-dnn.git
cd mkl-dnn/scripts && ./prepare_mkl.sh && cd ..
mkdir -p build && cd build
cmake -D CMAKE_INSTALL_PREFIX:PATH=<TARGET_DIR_IN_HOME> ..
make # this takes a while
make doc # do this optionally if you have doxygen
make test # also takes a while
make install # installs into <TARGET_DIR_IN_HOME>
add the following to your ~/.bashrc: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<TARGET_DIR_IN_HOME>/lib
Hope this helps!
Andres
You can install using conda with the following command.
conda install -c anaconda cudatoolkit
But you need to have prior accesss to the device(GPU).
EDIT : If you are finding error in anaconda repository then change the repository to conda-forge which is frequently updated.
conda install -c conda-forge cudatoolkit
You can install CUDA and compile programs, but you won't be able to run them for a lack of device access.

linker not working in Xcode -CUDA error [duplicate]

I'm currently trying to build a Cuda project with Cmake on MacOS 10.9. My C and C++ compiler are gcc, but it seems that since Mavericks gcc and g++ links to clang, which is not supported by CUDA.
Has anyone found a good solution to use the real gcc, or to make clang work without "dumpspecs"?
The issue with 10.9 is that gcc is actually clang. Please try latest CUDA toolkit and explicitely point NVCC to use /usr/bin/clang (nvcc -ccbin /usr/bin/clang). This way NVCC will know it's dealing with clang.
This is an extension of the answer provided by Eugene:
The CUDA toolkit download for Mac OSX 10.9 has been posted to the CUDA download page
It supports XCode 5 on 10.9, and will automatically use clang instead of gcc, FYI.
IF you are using XCode 5 on 10.8, please see the release notes:
ยท On Mac OS X 10.8, if you install XCode 5, including the command-line tools, the gcc compiler will get replaced with clang. You can continue to successfully compile with nvcc from the command-line by using the --ccbin /usr/bin/clang option, which instructs nvcc to use the clang compiler instead of gcc to compile any host code passed to it. However, this solution will not work when building with NSight Eclipse Edition. An alternative solution that will work from the command-line and with NSight Eclipse Edition is to download an older version of the command-line tools package from the Apple Developer website after installing XCode 5, which will re-install gcc to /usr/bin. In order to do this, go to
http://developer.apple.com/downloads/index.action
sign in with your Apple ID, and search for command-line tools using the search pane on the left side of the screen.
The problem actually was there before OS X Mavericks, I had the same problem with Moutain Lion and the answer from Eugene is 100% correct.
However, it seems that my Geforce card is not recognized as a CUDA capable device since the upgrade to Mavericks and it seems that people using softwares that use CUDA are having the same problems.
So better not update right now
I have just downloaded CUDA 5.5, installed under Mac OSX 10.8.5, with Xcode 5.0.2, and updated command line tools in Xcode.
But I couldn't get the CUDA sample "nbody" to compile.
I got all kinds of funny error messages, like clang error: unsupported option '-dumpspecs'
I thought I had solved that one by the help of some other web pages, but then other problems kept creeping up (e.g., GLEW not found, CUDA samples path undefined, ...).
(And the provided makefiles and cmake files seemed just too contrived, so that I couldn't find the bug.)
So I rolled my own makefile. I'm posting it here, in the hope that it might help others save some hours.
#!/usr/bin/make -R
# Simple Makefile for a CUDA sample program
# (because the provided ones don't work! :-( )
#
# We assume that all files in this directory produce one executable.
# Set your GPU version in variable NVCC below
#
# Developed and tested under Mac OS X 10.8.5;
# under Linux, you probably need to adjust a few paths, compiler options, and #ifdef's.
#
# Prerequisites:
# - CUDA 5.5
# - The "Command Line Tools" installed via XCode 5
# - DYLD_FALLBACK_LIBRARY_PATH or DYLD_LIBRARY_PATH must include
# /Developer/NVIDIA/CUDA-5.5/lib:/Developer/NVIDIA/CUDA-5.5/samples/common/lib/darwin
#
# GZ Dec 2013
# -------- variables and settings ---------
#
CUDA := /Developer/NVIDIA/CUDA-5.5
NVCC := nvcc -ccbin /usr/bin/clang -arch=sm_30 --compiler-options -Wall,-ansi,-Wno-extra-tokens
# -ccbin /usr/bin/clang is needed with XCode 5 under OSX 10.8
# -arch=sm_30 is needed for my laptop (it does not provide sm_35)
INCFLAGS := -I $(CUDA)/samples/common/inc
TARGET := nbody
OBJDIR := obj
MAKEFLAGS := kR
.SUFFIXES: .cu .cpp .h
ALLSOURCES := $(wildcard *.cu *.cpp)
ALLFILES := $(basename $(ALLSOURCES))
ALLOBJS := $(addsuffix .o,$(addprefix $(OBJDIR)/,$(ALLFILES)))
DEPDIR := depend
# --------- automatic targets --------------
.PHONY: all
all: $(OBJDIR) $(DEPDIR) $(TARGET)
#true
$(OBJDIR):
mkdir $#
# --------- generic rules --------------
UNAME = $(shell uname)
ifeq ($(UNAME), Darwin) # Mac OS X
# OpenGL and GLUT are frameworks
LDFLAGS = -Xlinker -framework,OpenGL,-framework,GLUT,-L,$(CUDA)/samples/common/lib/darwin,-lGLEW
endif
$(TARGET): $(ALLOBJS)
$(NVCC) $^ $(LDFLAGS) -o $#
$(OBJDIR)/%.o: %.cu
$(NVCC) -c $(INCFLAGS) $ $#
$(DEPDIR)/%.d : %.cpp $(DEPDIR)
#echo creating dependencies for $ $#
$(DEPDIR):
mkdir $#
# ------ administrative stuff -------
.PHONY: clean
clean:
rm -f *.o $(TARGET)
rm -rf $(DEPDIR) $(OBJDIR)
echo:
#echo $(ALLSOURCES)
#echo $(ALLFILES)
#echo $(ALLOBJS)
Clang become the default compiler with OsX Maverick release, gcc and g++ commands are redirected to the clang compiler. You can download gcc compiler via homebrew and link gcc and g++ commands back to the gcc compiler via following the steps below.
$ brew install gcc48
[...]
$ sudo mkdir /usr/bin/backup && sudo mv /usr/bin/gcc /usr/bin/g++ /usr/bin/backup
$ sudo ln -s /usr/local/bin/gcc-4.8 /usr/bin/gcc
$ sudo ln -s /usr/local/bin/g++-4.8 /usr/bin/g++
I have found the solution on this article:
http://gvsmirnov.ru/blog/tech/2014/02/07/building-openjdk-8-on-osx-maverick.html#all-you-had-to-do-was-follow-the-damn-train-cj
Here's a Homebrew recipe that works for me on Lion.
$ brew cat memtestG80
require "formula"
# Documentation: https://github.com/Homebrew/homebrew/wiki/Formula-Cookbook
# /usr/local/Library/Contributions/example-formula.rb
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
# Requires at compile time nvcc from https://developer.nvidia.com/cuda-downloads
# Requires popt at compile time
class Memtestg80 < Formula
homepage ""
url "https://github.com/ihaque/memtestG80/archive/master.zip"
sha1 ""
version "c4336a69fff07945c322d6c7fc40b0b12341cc4c"
# depends_on "cmake" => :build
depends_on :x11 # if your formula requires any X11/XQuartz components
def install
# ENV.deparallelize # if your formula fails when building in parallel
system "make", "-f", "Makefiles/Makefile.osx", "NVCC=/usr/local/cuda/bin/nvcc -ccbin /usr/bin/clang", "POPT_DIR=/usr/local/Cellar/popt/1.16/lib"
system "cp", "-a", "memtestG80", "/usr/local/bin"
end
test do
# `test do` will create, run in and delete a temporary directory.
#
# This test will fail and we won't accept that! It's enough to just replace
# "false" with the main program this formula installs, but it'd be nice if you
# were more thorough. Run the test with `brew test memtestG80`.
#
# The installed folder is not in the path, so use the entire path to any
# executables being tested: `system "#{bin}/program", "do", "something"`.
system "false"
end
end

Converting Octave to Use CuBLAS

I'd like to convert Octave to use CuBLAS for matrix multiplication. This video seems to indicate this is as simple as typing 28 characters:
Using CUDA Library to Accelerate Applications
In practice it's a bit more complex than this. Does anyone know what additional work must be done to make the modifications made in this video compile?
UPDATE
Here's the method I'm trying
in dMatrix.cc add
#include <cublas.h>
in dMatrix.cc change all occurences of (preserving case)
dgemm
to
cublas_dgemm
in my build terminal set
export CC=nvcc
export CFLAGS="-lcublas -lcudart"
export CPPFLAGS="-I/usr/local/cuda/include"
export LDFLAGS="-L/usr/local/cuda/lib64"
the error I receive is:
libtool: link: g++ -I/usr/include/freetype2 -Wall -W -Wshadow -Wold-style-cast
-Wformat -Wpointer-arith -Wwrite-strings -Wcast-align -Wcast-qual -g -O2
-o .libs/octave octave-main.o -L/usr/local/cuda/lib64
../libgui/.libs/liboctgui.so ../libinterp/.libs/liboctinterp.so
../liboctave/.libs/liboctave.so -lutil -lm -lpthread -Wl,-rpath
-Wl,/usr/local/lib/octave/3.7.5
../liboctave/.libs/liboctave.so: undefined reference to `cublas_dgemm_'
EDIT2:
The method described in this video requires the use of the fortran "thunking library" bindings for cublas.
These steps worked for me:
Download octave 3.6.3 from here:
wget ftp://ftp.gnu.org/gnu/octave/octave-3.6.3.tar.gz
extract all files from the archive:
tar -xzvf octave-3.6.3.tar.gz
change into the octave directory just created:
cd octave-3.6.3
make a directory for your "thunking cublas library"
mkdir mycublas
change into that directory
cd mycublas
build the "thunking cublas library"
g++ -c -fPIC -I/usr/local/cuda/include -I/usr/local/cuda/src -DCUBLAS_GFORTRAN -o fortran_thunking.o /usr/local/cuda/src/fortran_thunking.c
ar rvs libmycublas.a fortran_thunking.o
switch back to the main build directory
cd ..
run octave's configure with additional options:
./configure --disable-docs LDFLAGS="-L/usr/local/cuda/lib64 -lcublas -lcudart -L/home/user2/octave/octave-3.6.3/mycublas -lmycublas"
Note that in the above command line, you will need to change the directory for the second -L switch to that which matches the path to your mycublas directory that you created in step 4
Now edit octave-3.6.3/liboctave/dMatrix.cc according to the instructions given in the video. It should be sufficient to replace every instance of dgemm with cublas_dgemm and every instance of DGEMM with CUBLAS_DGEMM. In the octave 3.6.3 version I used, there were 3 such instances of each (lower case and upper case).
Now you can build octave:
make
(make sure you are in the octave-3.6.3 directory)
At this point, for me, Octave built successfully. I did not pursue make install although I assume that would work. I simply ran octave using the ./run-octave script in the octave-3.6.3 directory.
The above steps assume a proper and standard CUDA 5.0 install. I will try to respond to CUDA-specific questions or issues, but there are any number of problems that may arise with a general Octave install on your platform. I'm not an octave expert and I won't be able to respond to those. I used CentOS 6.2 for this test.
This method, as indicated, involves modification of the C source files of octave.
Another method was covered in some detail in the S3527 session at the GTC 2013 GPU Tech Conference. This session was actually a hands-on laboratory exercise. Unfortunately the materials on that are not conveniently available. However the method there did not involve any modification of GNU Octave source, but instead uses the LD_PRELOAD capability of Linux to intercept the BLAS library calls and re-direct (the appropriate ones) to the cublas library.
A newer, better method (using the NVBLAS intercept library) is discussed in this blog article
I was able to produce a compiled executable using the information supplied. It's a horrible hack, but it works.
The process looks like this:
First produce an object file for fortran_thunking.c
sudo /usr/local/cuda-5.0/bin/nvcc -O3 -c -DCUBLAS_GFORTRAN fortran_thunking.c
Then move that object file to the src subdirectory in octave
cp /usr/local/cuda-5.0/src/fortran_thunking.o ./octave/src
run make. The compile will fail on the last step. Change to the src directory.
cd src
Then execute the failing final line with the addition of ./fortran_thunking.o -lcudart -lcublas just after octave-main.o. This produces the following command
g++ -I/usr/include/freetype2 -Wall -W -Wshadow -Wold-style-cast -Wformat
-Wpointer-arith -Wwrite-strings -Wcast-align -Wcast-qual
-I/usr/local/cuda/include -o .libs/octave octave-main.o
./fortran_thunking.o -lcudart -lcublas -L/usr/local/cuda/lib64
../libgui/.libs/liboctgui.so ../libinterp/.libs/liboctinterp.so
../liboctave/.libs/liboctave.so -lutil -lm -lpthread -Wl,-rpath
-Wl,/usr/local/lib/octave/3.7.5
An octave binary will be created in the src/.libs directory. This is your octave executable.
In a most recent version of CUDA you don't have to recompile anything. At least as I found in Debian. First, create a config file for NVBLAS (a cuBLAS wrapper). It won't work without it, at all.
tee nvblas.conf <<EOF
NVBLAS_CPU_BLAS_LIB $(dpkg -L libopenblas-base | grep libblas)
NVBLAS_GPU_LIST ALL
EOF
Then use Octave as you would usually do running it with:
LD_PRELOAD=libnvblas.so octave
NVBLAS will do what it can on a GPU while relaying everything else to OpenBLAS.
Further reading:
Benchmark for Octave.
Relevant slides for NVBLAS presentation.
Manual for nvblas.conf
Worth noting that you may not enjoy all the benefits of GPU computing depending on used CPU/GPU: OpenBLAS is quite fast with current multi-core processors. So fast that time spend copying data to GPU, working on it, and copying back could come close to time needed to do the job right on CPU. Check for yourself. Though GPUs are usually more energy efficient.

How to compile qemu (for i386 only) on linux

I downloaded the tar.gz from qemu.org. Now how can I compile the source code only for i386 architecture?
I mean, my qemu need not be able to emulate a Power PC, Motorola 68000 or others.
I tried the steps
./configure
make
make install
But there was a failure
No rule to build target 'all'
Apart from this, the above steps compile the qemu for all architectures too.
Hope to get some help.
On Linux Machine Download Qemu Source Code and extract in directory then cd to DIR and do following:
./configure --disable-kvm [--prefix=PFX] [--target-list="i386-softmmu x86_64-softmmu"]
make
make install
first tar it (extract it)
then go to the directory on shell
then
type this commands
./configure --target-list=i386-softmmu
when build successful
press make and enter
when this done
then write
sudo make install
that's it
For general linux,
#tar xvzf qemu-1.4.0.tar.bz2
#cd qemu-1.4.0
#./configure --target-list=i386-softmmu
#make
#make install
For puppy linux wary 530,
#tar xvzf qemu-1.4.0.tar.bz2
#cd qemu-1.4.0
#./configure --target-list=i386-softmmu
#make
#new2dir make install
#cd ..
#dir2pet qemu-1.4.0-i486
./configure --target-list=x86_64-linux-user --disable-smartcard-nss
This command work for me, while building Qemu 1.6 on centOS

MySQL include files from Cygwin gcc

How can I set up MySQL so that i can have header-files and libraries in my Cygwin gcc C++ builds?
I have seen descriptions on the web, but it seems to refer to stuff I don't have, Like "configure.
(I suspect MySQL has changed their build system).
Using an older version could be an option, but I would prefer to have the same versions as on Linux.
I have a full Cygwin install.
First, what's wrong with just using the Windows version? It works fine.
Then, I've wanted to do the same thing as you, and it can be done. Note that I haven't attempted to build the server; all I was interested in was the MySQL client library so I could do some simple client development in the Cygwin environment.
So what do you have to do in order to build the client library on Cygwin?
First, get the tarball. I used mysql-5.5.13.tar.gz. Unpack it in a suitable location, like /usr/local/src.
Then, install the CMake build system via the Cygwin installer. MySQL has switched from GNU Autotools to CMake. CMake is a meta-build system. It generates Makefiles and other build scripts for specific build environments.
Of course, you also need make and gcc.
I had to apply an innocuous little patch posted on the MySQL forum by one Hiroaki Kawai in order to get the stuff to compile:
Finally, I renamed all dtoa() to _dtoa() in mysql/strings/dtoa.c.
The function is static, and should be safe to be renamed.
You can patch using Perl:
perl -pi.orig -e 's/\bdtoa\b/_dtoa/g' strings/dtoa.c
Then, in the top source directory, type:
cmake .
make mysqlclient
You'll get two static libraries in libmysql/, libclientlib.a and libmysqlclient.a. I don't know that the former is (possibly just a build artefact), but the latter is the real thing.
cp /usr/local/src/mysql-5.5/libmysql/libmysqlclient.a /usr/local/lib/
But it's static, and you likely want a dynamic library. This is where the Cygwin docs come in handy. So:
module=mysqlclient
gcc -shared -o cyg${module}.dll \
-Wl,--out-implib=lib${module}.dll.a \
-Wl,--export-all-symbols \
-Wl,--enable-auto-import \
-Wl,--whole-archive lib${module}.a \
-Wl,--no-whole-archive -lz
That'll create the shared library cygmysqlclient.dll and the import library libmysqlclient.dll.a. Copy both to /usr/local/bin. And that's it.
Here's another question on building the MySQL client library on Cygwin.