fastlib / fCWT

The fast Continuous Wavelet Transform (fCWT) is a library for fast calculation of CWT.
Apache License 2.0
263 stars 53 forks source link

Installation issues on Apple M1 #51

Open ShubhamPandey28 opened 1 year ago

ShubhamPandey28 commented 1 year ago

I tried installation using pip, but resulted in the following error

root ➜ /com.docker.devenvironments.code $ pip install fcwt
Collecting fcwt
  Downloading fCWT-0.1.18.tar.gz (4.6 MB)
     |████████████████████████████████| 4.6 MB 4.6 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Collecting numpy>=1.14.5
  Using cached numpy-1.26.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (14.2 MB)
Building wheels for collected packages: fcwt
  Building wheel for fcwt (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /tmp/tmpusb54r2k_in_process.py build_wheel /tmp/tmpkufqj71t
       cwd: /tmp/pip-install-4d9xmcij/fcwt_7b0325aac4424ab2bb629c22b7a61965
  Complete output (37 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-aarch64-cpython-39
  creating build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/fcwt.py -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/boilerplate.py -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/__init__.py -> build/lib.linux-aarch64-cpython-39/fcwt
  running egg_info
  writing fCWT.egg-info/PKG-INFO
  writing dependency_links to fCWT.egg-info/dependency_links.txt
  writing requirements to fCWT.egg-info/requires.txt
  writing top-level names to fCWT.egg-info/top_level.txt
  reading manifest file 'fCWT.egg-info/SOURCES.txt'
  adding license file 'LICENSE.txt'
  writing manifest file 'fCWT.egg-info/SOURCES.txt'
  copying src/fcwt/fcwt.cpp -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/fcwt.h -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/fcwt_wrap.cxx -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/fftw3.h -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/fftw3f.dll -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/fftw3f.lib -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/libfftw3f_ompl.so -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/libfftw3f_ompmac.a -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/libfftw3fl.so -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/libfftw3fmac.a -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/libomp.a -> build/lib.linux-aarch64-cpython-39/fcwt
  copying src/fcwt/omp.h -> build/lib.linux-aarch64-cpython-39/fcwt
  running build_ext
  building 'fcwt._fcwt' extension
  creating build/temp.linux-aarch64-cpython-39
  creating build/temp.linux-aarch64-cpython-39/src
  creating build/temp.linux-aarch64-cpython-39/src/fcwt
  aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Isrc/fcwt -Isrc -Ilibs -I/tmp/pip-build-env-supkdnf8/overlay/lib/python3.9/site-packages/numpy/core/include -I/usr/include/python3.9 -c src/fcwt/fcwt.cpp -o build/temp.linux-aarch64-cpython-39/src/fcwt/fcwt.o -std=c++17 -mavx -O3
  aarch64-linux-gnu-gcc: error: unrecognized command-line option ‘-mavx’
  error: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for fcwt
Failed to build fcwt
ERROR: Could not build wheels for fcwt which use PEP 517 and cannot be installed directly

I added some changes in the cmake file SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -march=native -O2") instead of "-mavx"

And I tried to install and use the C++ endpoint but I am getting segmentation faults on FCWT::cwt.

int main(){
    std::cout << "The server started." << std::endl;

    std::string filepath = "../static/sample.csv";
    int nchannels = 6;

    std::vector<std::vector<float>> data = readCSV(filepath, 6); // this part will be replaced with an active socket connection received
    std::cout << "File read successfully. Size " << data.size() <<","<<data[0].size() << std::endl;

    int sampling_rate = 44100;
    int nframe = 128;
    int nsamples = data[0].size();
    int fstart = 1, fend = 64;

    Morlet morlet(2.0f);
    Wavelet *wavelet = &morlet;
    int nthreads = 8;

    FCWT fcwt(wavelet, nthreads, true, false);

    Scales scales(wavelet,  FCWT_LOGSCALES, sampling_rate, fstart, fend, nframe);

    std::vector<MatrixXcf> spectrum(nframe, MatrixXcf::Zero(nchannels, nsamples));

    std::cout << nchannels << std::endl;
    std::vector<complex<float>> spec(data.size()*data[0].size() + 5, 0);
    std::cout << spec[0] << std::endl;

    for (int i = 0; i < nchannels; i++)
    {
        std::cout << i << std::endl;
        fcwt.cwt(&data[i][0], nsamples, &spec[0], &scales);
        std::cout << "good" << std::endl;
        std::cout << spec[0] << std::endl;
    }

}
[100%] Linking CXX executable server
[100%] Built target server
The server started.
File read successfully. Size 6,8000
6
(0,0)
0
WARNING: Optimization scheme 'n8192_t8.wis' was not found, fallback to calculation without optimization.
Segmentation fault

How should I rectify this?