i always get the following error "Error in magma_getdevice_arch: MAGMA not initialized (call magma_init() first) or bad device" whenever i run a very simple code using google colab with magma-2.6.1 installed.
////////////////////////
#include <iostream>
#include "cublas_v2.h"
#include "magma_v2.h"
#include "magma_lapack.h"
using namespace std;
int main ( int argc , char **argv ){
magma_init();
magma_getdevice_arch();
magma_finalize();
return 0;
}
It seems that this issue has to do with a version of PyTorch too new for the version of CUDA installed on Colab Systems.
Run pip install --user torch==1.9.0 torchvision==0.10.0 torchaudio==0.9.0 torchtext==0.10.0 to downgrade.
Answer taken from: https://www.kaggle.com/product-feedback/279990
Related
I am testing openssl under macos.
First, I installed openssl through brew install openssl, and the installation location is: /usr/local/Cellar/openssl#3/3.0.5/.
Then I created a simple macos command line project, and then wrote some very simple code to reference the openssl encryption and decryption library.
In order to pass the compilation, I added the include path of openssl in the header file search path.
Then I added a reference to libcrypto.a in the Build Phase options. From what I understand, this library should be a static library, then when linking, the linker should copy all its code into my process without adding references to other dynamic libraries. But the strange thing is that when I try to debug and run the project, the process actually tries to load a dynamic library libcrypto.3.dylib that I have never referenced, and the loading fails because the dynamic library has no signature.
dyld[4481]: Library not loaded: '/usr/local/opt/openssl#3/lib/libcrypto.3.dylib'
Referenced from: '/Users/dongbo/Library/Developer/Xcode/DerivedData/TestOpenSSL-abmortoxmqaalbcuirkuraizktsa/Build/Products/Debug/TestOpenSSL'
Reason: tried: '/Users/dongbo/Library/Developer/Xcode/DerivedData/TestOpenSSL-abmortoxmqaalbcuirkuraizktsa/Build/Products/Debug/libcrypto.3.dylib' (no such file), '/usr/lib/system/introspection/libcrypto.3.dylib' (no such file), '/usr/local/opt/openssl#3/lib/libcrypto.3.dylib' (code signature in <BF9EFA44-EE24-3AF6-B0D4-3DFC6E454288> '/usr/local/Cellar/openssl#3/3.0.5/lib/libcrypto.3.dylib' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.), '/usr/local/lib/libcrypto.3.dylib' (no such file), '/usr/lib/libcrypto.3.dylib' (no such file), '/Users/dongbo/Library/Developer/Xcode/DerivedData/TestOpenSSL-abmortoxmqaalbcuirkuraizktsa/Build/Products/Debug/libcrypto.3.dylib' (no such file), '/usr/lib/system/introspection/libcrypto.3.dylib' (no such file), '/usr/local/Cellar/openssl#3/3.0.5/lib/libcrypto.3.dylib' (code signature in <BF9EFA44-EE24-3AF6-B0D4-3DFC6E454288> '/usr/local/Cellar/openssl#3/3.0.5/lib/libcrypto.3.dylib' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.), '/usr/local/lib/libcrypto.3.dylib' (no such file), '/usr/lib/libcrypto.3.dylib' (no such file)
Program ended with exit code: 9
I'm getting this error while testing on an intel-architecture imac, but magically, I'm doing the same on an m1 with no issues, except my m1 pro has sip turned off.
I don't know if everyone knows the reason for this?
all test codes:
#import <Foundation/Foundation.h>
#include <string>
#include <openssl/rsa.h>
#include <openssl/pem.h>
const std::string pk = std::string("-----BEGIN PUBLIC KEY-----\n") +
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDTlCZFucurE+QNupniPUXz5RwN\n" +
"dhRAplB+jd51U4NTcpDl4AL3LppKdRxEyt4FlvLiE66tmonEJTc4BcaRurxxXOuY\n" +
"+0IS4l28FynYT/yDpdoiop0Jf2NCa8V5nCBISKp1Lgvz7AbHBw+3KNCF1UdrOeRs\n" +
"r/GBOSXosmTzPMRUNwIDAQAB\n" +
"-----END PUBLIC KEY-----";
std::string decrypt_string(const void* data, size_t length)
{
BIO* bio = BIO_new_mem_buf(pk.c_str(), (int)pk.size());
RSA* rsa = NULL;
PEM_read_bio_RSA_PUBKEY(bio, &rsa, 0, 0);
char buf[1024] = {0};
int ret = RSA_public_decrypt(0x80, (const unsigned char*)data, (unsigned char*)buf, rsa, RSA_PKCS1_PADDING);
if(ret == -1)
{
BIO_free(bio);
printf("decrypt error:%d\n", ret);
return "Error";
}
BIO_free(bio);
std::string str = buf;
return buf;
}
int main(int argc, const char * argv[]) {
#autoreleasepool {
// insert code here...
NSLog(#"Hello, World!");
}
return 0;
}
First, openssl is in fact considered deprecated and the corresponding headers were removed from macOS SDK 10.11 (the replacement is Secure Transport API).
Second, when linking a libName.a archive from Xcode settings, Xcode in fact transform this into -lName flag when linking. It means Xcode doesn't refer to any specific path you provided, but instead looks for appropriate libraries in the default search-libs paths (in addition to the provided ones).
If for any reason you still need the library Apple recommends just build it locally and embed the archive in the project bundle:
Add the library archive to the project:
Provide path to the system headers (it can be just headers paths, but i prefer system headers for 3-rd party libraries to avoid redundant warnings):
Add the archive to Embed Frameworks but not Link Binary build phases (we avoid using Link Binary step because if the library exists in the outdated macOS SDK, Xcode mail fail to disambiguate it with the embedded version):
Add linker flag to the Build Settings which points to your archive in the project directory (don't worry that such a directory doesn't exist for a product, the Embed Frameworks phase will resolve this path into the correct one):
At this point the library should link without errors.
I was trying use build wxWidgets-3.1.3 with MinGW-W64 on a x64 windows machine.
I followed this thread, which lead me to download and building. So I installed it and some youtube videos said I need to build it now. So navigate to the installed folder and gave this command :
mingw32-make -f makefile.gcc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1.
It took almost half an hour and now it's giving me error saying :
collect2.exe: error: ld returned 1 exit status
makefile.gcc:5329: recipe for target '..\..\lib\gcc_dll\wxmsw313u_gcc_custom.dll' failed
mingw32-make: *** [..\..\lib\gcc_dll\wxmsw313u_gcc_custom.dll] Error 1
Here is the full log file :
https://pastebin.com/zxeHhF6K
MinGW configuration :
Version : 8.1.0
Architecture : x86_64
Threads : posix
Exceptions : seh
Build version : 0
How can I solve this? I'm using CLion, is there any other short or easy way?
The relevant error is
..\..\lib\gcc_dll/libwxexpat.a(wxexpat_xmlparse.o):xmlparse.c:(.text+0x337d): undefined reference to `_imp__rand_s'
and it's very strange because MinGW-w64 8.1 is definitely supposed to have rand_s(). Are you sure you're using the right compiler? I.e. what does g++ -v give you if you run it from the same command prompt?
My only hypothesis is that it's some different (and much older) compiler and the solution would be to just use the right one instead.
Also, the next time you could use -j4 option with make if you have at least 4 logical CPUs in your machine (and chances are you do nowadays), to significantly speed up the build.
Looking back in my notes I once had an issue with missing rand_s() when building glib2 on a certain MinGW build.
I was able to fix it then by adding this at the top of the C file that called this function:
#include <time.h>
#include <stdlib.h>
int rand_s (unsigned int* r)
{
static int srand_called = 0;
if (!srand_called) {
srand(time(0));
srand_called++;
}
if (r)
*r = rand();
return 0;
}
In your case that would be in xmlparse.c.
I am trying to use the library found here:
https://tmrh20.github.io/RF24/RPi.html
I am running an RPi 2 B+ with Raspbian current 11/12/15
I have the example working on Arduino and I have no issues communicating Arduino to Arduino. However when attempting to use the RPi example I end up with this error.
pi#raspberrypi ~/Desktop/rf24 $ cd rf24libs/RF24/examples_RPi/
pi#raspberrypi ~/Desktop/rf24/rf24libs/RF24/examples_RPi $ make
g++ -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -Wall -I../ -lrf24-bcm transfer.cpp -o transfer
transfer.cpp: In function ‘int main(int, char**)’:
transfer.cpp:129:10: error: ‘sleep’ was not declared in this scope
sleep(2);
^
Makefile:32: recipe for target 'transfer' failed
make: *** [transfer] Error 1
The instructions are incredibly simple:
wget http://tmrh20.github.io/RF24Installer/RPi/install.sh
chmod +x install.sh
./install.sh
cd rf24libs/RF24/examples_RPi
make
sudo ./gettingstarted
So I would expect something that is "out of the box" to function normally correct? Apparently not...
I also have the library that is required for the build, found here:
http://www.airspayce.com/mikem/bcm2835/
I have it installed and ready to go. But in order to continue I need to be able to get this basic gettingstarted example to function. I am new to using GPIO but I have followed the diagram on this page:
https://raspberrypi.stackexchange.com/questions/22490/rf24-communication-with-arduino
TL;DR
I cannot get the basic example to function based off code found in a well documented and commonly used library using RF24 modules utilizing RPi and the gettingstarted example included in the library.
I invite you to download this and try installing it yourselves on your RPi to see if we all have the same issues. Maybe we can solve this once and for all.
Any help will be much appreciated and I will be monitoring this thread.
Thank you.
Add the following include below the existing includes in transfer.cpp... It'll look like this...
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <RF24/RF24.h>
#include <unistd.h>
Afterwords verify that sleep is lowercase:
if (role == role_ping_out){
sleep(2);
printf("Initiating Basic Data Transfer\n\r");
Should compile now...
I recently installed the hdf5 library on an ubuntu machine, and am now having trouble linking to the exported functions. I wrote a simple test script readHDF.cpp to explain the issue:
#include <hdf5.h>
int main(int argc, char * argv[])
{
hid_t h5_file_id = H5Fopen(argv[1], H5F_ACC_RDWR, H5P_DEFAULT);
return 0;
}
The compile command is
g++ -Wl,-rpath,$HOME/hdf5/lib -I$HOME/hdf5/include \
-L$HOME/hdf5/lib -l:$HOME/hdf5/lib/libhdf5.so readHDF.cpp
which returns the following error
/tmp/cc6DXdxV.o: In function `main':
readHDF.cpp:(.text+0x1f): undefined reference to `H5check_version'
readHDF.cpp:(.text+0x3c): undefined reference to `H5Fopen'
collect2: ld returned 1 exit status
I am confused because the nm command seems to say that the function has been exported:
nm -C $HOME/hdf5/lib/libhdf5.so | grep H5check_version
which returns
0000000000034349 T H5check_version
and a similar result for H5Fopen. Any thoughts on what might be going wrong? Not sure if it helps, but if I comment out the H5Fopen portion of the script, then it compiles fine:
#include <hdf5.h>
int main(int argc, char * argv[])
{
hid_t h5_file_id;// = H5Fopen(argv[1], H5F_ACC_RDWR, H5P_DEFAULT);
return 0;
}
Also there are multiple versions of hdf5 installed on the server which are used by various python modules such as h5py and tables, but I couldn't get any of them to work, so I installed this version in my local directory and changed the rpath options for g++ linker.
Ok, solved. The issue was in the placement of the -lhdf5 in the compile command. Apparently -lhdf5 should be placed after readHDF.cpp. For instance g++ -Wl,-rpath=$HOME/hdf5/lib -L$HOME/hdf5/lib -I$HOME/hdf5/include readHDF.cpp -lhdf5 will compile with no problems, but g++ -Wl,-rpath=$HOME/hdf5/lib -L$HOME/hdf5/lib -I$HOME/hdf5/include -lhdf5 readHDF.cpp will fail with the undefined reference errors. Interestingly, this was only a problem for Ubuntu 12.04, as both compile commands worked for Ubuntu 10.04.
Found the answer with explanation at this post:
undefined reference to symbol even when nm indicates that this symbol is present
I guess placing -lXXX after the script is safer practice.
This is not a bug. See
C++ shared library undefined reference to `FooClass::SayHello()'
"Recent versions of GCC reuqire that you put the object files and libraries in the order that they depend on each other ..."
You forgot to put -lhdf5 in the compile command. Also, there's no need for -l:$HOME/hdf5/lib/libhdf5.so
This should work: $ g++ -Wl,-rpath,$HOME/hdf5/lib -I$HOME/hdf5/include -L$HOME/hdf5/lib -lhdf5 readHDF5.cpp
I want to create a custom GTK module which should be loaded when I start a GTK application.
Documentation on this topic is rare, I searched a lot but I failed to get it running. I'm on Ubuntu Linux with GTK3 and tried sofar:
Compiled and linked a shared library with the method void gtk_module_init(gint *argc, gchar ***argv[]) inside. As far as I understood, this should be enough to create a simple module. Full code:
#include <iostream>
#include <gtk/gtk.h>
void gtk_module_init(gint *argc, gchar ***argv[]) {
std::cout << "huhu" << std::endl;
}
Put this lib into /usr/lib/x86_64-linux-gnu/gtk-3.0/modules/libtest-gtk-module.so
Tried to launch an application like this: gnomine --gtk-module=libtest-gtk-module.so But all I get is: Gtk-Message: Failed to load module "libtest-gtk-module.so"
So what else has to be done in order to make GTK load this library?
Many thanks in advance!
You need to make the system aware of the library. For a library in a system directory, it should be enough to run ldconfig as root. Take a look at the tutorial here.
[EDIT]
I got the module to load as follows:
Since this is C++ code, you need to make sure the function name isn't name mangled:
extern "C" {
void gtk_module_init(gint *argc, gchar ***argv[]) {
std::cout << "huhu" << std::endl;
}
}
I built it with the following:
g++ -fPIC -shared -Wl,-soname,libfoo.so.1 -olibfoo.so.1.0.1 `pkg-config --libs --cflags gtk+-3.0` t.c
I used an absolute path to avoid messing with ldconfig, this is probably the best thing to do while developing the module:
~$ gedit --gtk-module=/home/eric/libfoo.so.1.0.1 t.c
huhu
This is on Mint LMDE, not Ubuntu, but I don't think it matters.
Try to run it with strace:
strace -eopen add_your_command_here 2>&1 | grep libtest-gtk-module.so
You'll find out where your program is looking for that file.