Random Forest Distance for Python fails to build (g++) - python

this implementation of RFD http://www.cse.buffalo.edu/~jcorso/r/snippets.metric_learning.html
fails to build for me. Running the setup.py within the python package, when the following appears:
Building Swig Modules:
building librf...
/tmp/cctKDjwA.s: Assembler messages:
/tmp/cctKDjwA.s:12665: Error: no such instruction: `vfnmadd312ss 52(%r14),%xmm5,%xmm2'
/tmp/cctKDjwA.s:14338: Error: no such instruction: `vfnmadd312ss 84(%rdx),%xmm5,%xmm2'
/tmp/cctKDjwA.s:18244: Error: no such instruction: `vfnmadd312ss 228(%rsp),%xmm1,%xmm3'
/tmp/cctKDjwA.s:18389: Error: no such instruction: `vfmadd312ss 272(%rsp),%xmm1,%xmm0'
The line where it fails (checked separately):
os.system("g++ -march=native -fPIC -O3 -std=c++0x -c src/librf_wrap.cxx src/librf/*.cc src/librf/semaphores/*.cpp -I/usr/include/" + pyver)
I'm running on Ubuntu 12.04 64-bit with i5-4430. Apologies, but I'm unsure what additional info I should add, please suggest.
Thanks for your patience.

It's possible that '-march=native' is incorrectly determining your CPU and generating instructions that are illegal for it.
Could you try without '-march=native' to see if that is the case?
Note that it's possible to see what '-march=native' is choosing exactly, see this website.

Related

Error while creating dll from C code for Python code

I have some C code which uses "mex.h". I am trying to create shared library (ie create dll file) so that it can be used in Python by using ctypes library.
Following is the command that I have tried for creating dll file, but I am getting an error.
Command Used
gcc -fPIC -IC:\Progra~1\MATLAB\R2020b\extern\include -IC:\Progra~1\MATLAB\R2020b\extern\lib -lC:\Progra~1\MATLAB\R2020b\bin\win64\libmat.dll -lC:\Progra~1\MATLAB\R2020b\bin\win64\libmx.dll -shared -o whitsmw_Cd1.dll whitsmw_Cd1.c
Error
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lC:\Progra~1\MATLAB\R2020b\bin\win64\libmat.dll
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lC:\Progra~1\MATLAB\R2020b\bin\win64\libmx.dll
collect2.exe: error: ld returned 1 exit status
I have checked the paths are correct. I would be helpful if someone can provide some help.

Find what the PyCUDA compilation error was

I'm trying to compile a PyCUDA kernel. The compilation fails with the error:
pycuda.driver.CompileError: nvcc preprocessing of C:\Users\itay\AppData\Local\Temp\tmp78b6tln1.cu failed
[command: nvcc --preprocess -arch sm_52 -m64 -Ic:\users\itay\sources\pythonmaps\env\lib\site-packages\pycuda\cuda C:\Users\itay\AppData\Local\Temp\tmp78b6tln1.cu --compiler-options -EP]
Running the same command from a command prompt works fine.
The CompileError exception has a strerr attribute which contains the stderr of the compilation. It is empty. Only by placing a break-point inside PyCUDA did I find the actual error, which was reported by nvcc to stdout.
Is there a way to get the compilation output without placing breakpoints in PyCUDA?

Installing the "ring.cx SIP client" on a Raspberry PI

The Situation
I would like to get terminal-based (headless) SIP calls working on my Raspberry Pi and I already tried this using linphone:
RaspberryPI: Making SIP outbound calls using linphonec or an alternative SIP soft phone
Since I am currently stuck there I wanted to try another option which was SFLPhone. They pointed me towards the ring software project which offers a daemon dring which allows making SIP calls using a scripting interface:
Indeed, the daemon can run standalone and be controlled using the DBus API.
Note the project have been renamed to "Ring" (version is bumped to 2.x). Experimental packages are available at http://ring.cx/en/documentation/linux-installation
A major feature of Ring
2.x is the optional "DHT" account type allowing to make calls without any SIP server.
There are many other enhancements such as ICE support, UPnP support, stability improvements etc.
(note clients are being re-written (GTK3, Qt5) and there is a new OS X client, they are not yet feature complete and in heavy development.)
The new daemon dring source Git repo URI is : https://gerrit-ring.savoirfairelinux.com/ring .
The DBus API is mostly the same as before. In the tools/dringctrl directory you will find an example python client that we use for testing (uses python3-dbus).
We are willing to fix any bugs you may find, the daemon bugtracker is here : https://projects.savoirfairelinux.com/projects/ring-daemon/issues
Also look at https://projects.savoirfairelinux.com/projects/ring/wiki for build instruction etc.
Regards and good luck for your embedded project,
A. B.
Compiling the dependencies
I tried to compile the dependencies for the project like stated in the README:
git clone https://gerrit-ring.savoirfairelinux.com/ring
cd ring
Compile the dependencies first
cd ../contrib/
rm -fr native/ && mkdir native
cd native
../bootstrap
make
I got this error:
libvpx.webm-4640a0c4804b/third_party/googletest/src/include/gtest/gtest.h
mv libvpx-4640a0c4804b49f1870d5a2d17df0c7d0a77af2f libvpx && touch libvpx
cd libvpx && CROSS= ./configure --target=armv7-linux-gcc \
--as=yasm --disable-docs --disable-examples --disable-unit-tests --disable-install-bins --disable-install-docs --enable-realtime-only --enable-error-concealment --disable-runtime-cpu-detect --disable-webm-io --enable-pic --prefix=/home/pi/ring/contrib/arm-linux-gnueabihf
disabling docs
disabling examples
disabling unit_tests
disabling install_bins
disabling install_docs
enabling realtime_only
enabling error_concealment
disabling runtime_cpu_detect
disabling webm_io
enabling pic
Configuring selected codecs
enabling vp8_encoder
enabling vp8_decoder
enabling vp9_encoder
enabling vp9_decoder
Configuring for target 'armv7-linux-gcc'
enabling armv7
enabling neon
enabling neon_asm
enabling media
Unable to invoke compiler: arm-none-linux-gnueabi-gcc -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
Configuration failed. This could reflect a misconfiguration of your
toolchains, improper options selected, or another problem. If you
don't see any useful error messages above, the next step is to look
at the configure error log file (config.log) to determine what
configure was trying to do when it died.
../../contrib/src/vpx/rules.mak:105: recipe for target '.vpx' failed
make: *** [.vpx] Error 1
Compiling ring
Despite compiling the dependencies failed I did attempt to compile ring:
git clone https://gerrit-ring.savoirfairelinux.com/ring
cd ring
./autogen.sh
./configure
make
make install
This caused the following error:
checking for PJPROJECT... no
configure: error: Missing pjproject files
pi#phone ~/ring $ make
make: *** No targets specified and no makefile found. Stop.
pi#phone ~/ring $ make install
make: *** No rule to make target 'install'. Stop.
So currently I am stuck and I fear that I will not be able to go beyond the current state of my project (🎥):
Edit: Now without the video codecs (like aberaud suggested) I run into the following error:
/bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -I../include/opendht -I/home/pi/sip-desaster/ring/contrib/arm-linux-gnueabihf/include -fPIC -I/home/pi/sip-desaster/ring/contrib/arm-linux-gnueabihf/include -g -fPIC -O3 -std=c++0x -I/home/pi/sip-desaster/ring/contrib/arm-linux-gnueabihf/include -g -fPIC -O3 -std=c++0x -c -o libopendht_la-dht.lo `test -f 'dht.cpp' || echo './'`dht.cpp
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -I../include/opendht -I/home/pi/sip-desaster/ring/contrib/arm-linux-gnueabihf/include -fPIC -I/home/pi/sip-desaster/ring/contrib/arm-linux-gnueabihf/include -g -fPIC -O3 -std=c++0x -I/home/pi/sip-desaster/ring/contrib/arm-linux-gnueabihf/include -g -fPIC -O3 -std=c++0x -c dht.cpp -fPIC -DPIC -o libopendht_la-dht.o
In file included from ../include/opendht/dht.h:29:0,
from dht.cpp:27:
../include/opendht/infohash.h:58:22: error: expected initializer before ‘:’ token
dht.cpp:3105:1: error: expected ‘}’ at end of input
Makefile:386: recipe for target 'libopendht_la-dht.lo' failed
make[2]: *** [libopendht_la-dht.lo] Error 1
make[2]: Leaving directory '/home/pi/sip-desaster/ring/contrib/native/opendht/src'
Makefile:395: recipe for target 'install-recursive' failed
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory '/home/pi/sip-desaster/ring/contrib/native/opendht'
../../contrib/src/opendht/rules.mak:28: recipe for target '.opendht' failed
make: *** [.opendht] Error 2
Contrib
The "contrib" part of the Ring build is about building dependencies that are not available on the target system, mostly used to build full working packages when cross-compiling or for systems without proper dependency management (basically all OSs except Linux distros).
When in the contrib/native directory, you can run make list to see the list of packages to be built. Since you are cross-compiling you will need to build almost everything.
If you somehow mess up the contrib build you can safely delete the contrib/native and contrib/{target_tuple} (if any) directories and start again.
libvpx
The libvpx library is used by libav to provide the vp8 and vp9 video codecs. It's not an hard dependency and since your project doesn't use video you can safely disable it. We also encountered issues when cross compiling vpx.
In contrib/src/libav/rules.mak line 70, DEPS_libav defines the list of dependencies for libav. You can remove vpx, x264 and $(DEPS_vpx) from the list since you don't use video. You may also add speex and opus audio codecs to the list (they should be in the list but aren't, see this patch
as an example).
After cleaning contrib as described above and boostraping again, when running make list, vpx and x264 shouldn't show up in the list of "To-be-built packages". Then try to build contrib by running make.
If after trying this you encounter the same issue for other packages you may have some sort of cross compilation build path issue (I would then need more logs/details).
As a very last resort, compiling on the Pi itself (with Raspbian) is horribly slow but has the advantage to use local distro-provided dependencies and remove the hassles of cross compilation.
Good luck
I am providing an own answer which should document my steps which will hopefully lead me to the desired end result:
Download the sources
git clone https://gerrit-ring.savoirfairelinux.com/ring
cd ring
Build the contrib section
According to #aberaud's remarks I can update contrib/src/libav/rules.mak and remove any video-related dependencies (remember that I am headless):
So I changed line 70 form
DEPS_libav = zlib x264 vpx $(DEPS_vpx)
to
DEPS_libav = zlib opus speex
Now build the contrib section.
cd ../contrib/
rm -fr native/ && mkdir native
cd native
../bootstrap
make
I was hitting the same error trying to compile the contrib.
The version of Raspbian I was using came with the older version of the gcc compiler, version 4.6. After I upgraded to 4.8 it compiled instantly. Well, as instantly as anything compiles on the Pi at any rate.

Compile PJSUA on OS X 10.9

First time using stackoverflow, please tell me, if I'm doing something wrong!
I want to use PJSIP 2.1s python module (wrapper). I tried it like so:
Read the documentation.
Check the requirements accordingly. This is my setup:
OS X 10.9 (Mavericks)
GNU Make 3.81
binutils 2.23.2 (probably via Macports.. not actually sure)
Apple LLVM 5.0
Download v2.1: pjproject-2.1.tar.bz2 and extracted it into my home dir.
Cd into pjproject-2.1 and run this in terminal: ./configure && make dep && make.
When it comes to this line (which is during make, I believe): gcc -o ../bin/pjmedia-test-i386-apple-darwin13.0.0, the following error gets thrown right into my face :/
Undefined symbols for architecture x86_64:
"_aes_icm_advance_ismacryp", referenced from:
_aes_icm_encrypt_ismacryp in libsrtp-i386-apple-darwin13.0.0.a(aes_icm.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../bin/pjmedia-test-i386-apple-darwin13.0.0] Error 1
make[1]: *** [pjmedia-test] Error 2
make: *** [all] Error 1
The script then aborts.
Do you have any suggestions, what might be the problem, or how to avoid it? Will be glad for any help!
Would it help, to force gcc to compile to 32 bit?
i am not sure, if this solves your problem, but for me it worked:
Disable SRTP (Secure Real-Time Transport Protocol)
Add the following to the file pjlib/include/pj/config_site.h
#define PJMEDIA_HAS_SRTP 0
make again - should work.
The right solution would be to reimplement the missing structure in the c code. Probably better to wait for a patch.

"cannot find -lpq" when trying to install psycopg2

Intro: I'm trying to migrate our Trac SQLite to a PostgreSQL backend, to do that I need psycopg2. After clicking past the embarrassing rant on www.initd.org I downloaded the latest version and tried running setup.py install. This didn't work, telling me I needed mingw. So I downloaded and installed mingw.
Problem: I now get the following error when running setup.py build_ext --compiler=mingw32 install:
running build_ext
building 'psycopg2._psycopg' extension
writing build\temp.win32-2.4\Release\psycopg\_psycopg.def
C:\mingw\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.4\Release\psycopg
\psycopgmodule.o build\temp.win32-2.4\Release\psycopg\pqpath.o build\temp.win32-
2.4\Release\psycopg\typecast.o build\temp.win32-2.4\Release\psycopg\microprotoco
ls.o build\temp.win32-2.4\Release\psycopg\microprotocols_proto.o build\temp.win3
2-2.4\Release\psycopg\connection_type.o build\temp.win32-2.4\Release\psycopg\con
nection_int.o build\temp.win32-2.4\Release\psycopg\cursor_type.o build\temp.win3
2-2.4\Release\psycopg\cursor_int.o build\temp.win32-2.4\Release\psycopg\lobject_
type.o build\temp.win32-2.4\Release\psycopg\lobject_int.o build\temp.win32-2.4\R
elease\psycopg\adapter_qstring.o build\temp.win32-2.4\Release\psycopg\adapter_pb
oolean.o build\temp.win32-2.4\Release\psycopg\adapter_binary.o build\temp.win32-
2.4\Release\psycopg\adapter_asis.o build\temp.win32-2.4\Release\psycopg\adapter_
list.o build\temp.win32-2.4\Release\psycopg\adapter_datetime.o build\temp.win32-
2.4\Release\psycopg\_psycopg.def -LC:\Python24\libs -LC:\Python24\PCBuild -Lc:/P
ROGRA~1/POSTGR~1/8.3/lib -lpython24 -lmsvcr71 -lpq -lmsvcr71 -lws2_32 -ladvapi32
-o build\lib.win32-2.4\psycopg2\_psycopg.pyd
C:\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot fin
d -lpq
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
What I've tried - I noticed the forward slashes in the -L option, so I manually entered my PostgreSQL lib directory in the library_dirs option in the setup.cfg, to no avail (the call then had a -L option with backslashes, but the error message stayed the same).
Have you tried the binary build of psycopg2 for windows? If that works with your python then it mitigates the need to build by hand.
I've seen random people ask this question on various lists and it seems one recommendation is to build postgresql by hand to work around this problem.
Compiling extensions on windows can be tricky. There are precompiled libraries available however: http://www.stickpeople.com/projects/python/win-psycopg/

Categories