Git Product home page Git Product logo

waifu2x-converter-cpp's Introduction

waifu2x (converter only version)

This is a reimplementation of waifu2x (original) converter function, in C++, using OpenCV. This is also a reimplementation of waifu2x python version by Hector Martin. You can use this as command-line tool of image noise reduction or/and scaling.

Prebuilt binary-form release

works using waifu2x-converter

  • waifu2x_win_koroshell
    • waifu2x-converter GUI frontend that is easy to use, and so cute. You need only drag&drop to convert your image. (and also you can set converting mode, noise reduction level, scale ratio, etc..., on GUI)
    • Both waifu2x-converter x86 and x64 are included this package, and GUI see your windows architecture(x86|x64) and selects automatically which to use.
    • For windows only.

Dependencies

Platform

  • Ubuntu
  • Mac OS X?
  • Windows

(This program probably can be built under MacOSX, because OpenCV and other libraries support OS X)

Libraries

  • OpenCV(C++, version 3.0.0 rc1)

This programs also depends on libraries shown below, but these are already included in this repository. CUDA Support in OpenCV is optional, since not required. (in version 1.0.0, CUDA Support is not used.)

How to build

for Ubuntu

Sorry, under construction...

These are hints for building :

  • I recommend to install OpenCV from sources. (build instruction is found here)
  • include path : include/ (/path/to/opencv/installed/directory)/include
  • library path : (/path/to/opencv/installed/directory)/lib
    • if you have built and installed OpenCV from source, and have changed install directory(by using CMAKE_INSTALL_PREFIX), you may need to set environment variable LD_LIBRARY_PATH for your OpenCV installed directory.
  • libraries to link : opencv_core opencv_imgproc opencv_imgcodecs opencv_features2d
  • standard of C++ : c++11

Usage

Usage of this program can be seen by executing this with --help option.

(My native language is not English, then I'm sorry for my broken English.)

modifided by tanakamura

  • Added CUDA, OpenCL(AMD GPU), x86 FMA, x86 AVX Support (That is selected automatically at runtime)
  • OpenCL(AMD GPU) version achieves 40% of peak performance (291GFLOPS @ A10-7850K)
  • Added CMakeLists.txt
  • You can build it by cmake ($ cmake -D OPENCV_PREFIX=<OpenCV include/lib dir>)
  • DLL interface
  • You can use waifu2x as library. include w2xconv.h & link w2xc.lib.

waifu2x-converter-cpp's People

Contributors

holywu avatar iwag avatar jbeich avatar professorjamesmoriarty avatar tanakamura avatar vitaliylag avatar wl-amigo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

waifu2x-converter-cpp's Issues

Compile error on Linux : no CL/opencl.h

Hi tanakamura,
I tried to compile your project on a CentOS 7 with a Tesla K40 (CUDA 7) but it failed:

[ 31%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler.cpp.o
In file included from /home/enigma/waifu2x/waifu2x-converter-cpp-master/src/Buffer.hpp:41:0,
from /home/enigma/waifu2x/waifu2x-converter-cpp-master/src/modelHandler.hpp:19,
from /home/enigma/waifu2x/waifu2x-converter-cpp-master/src/modelHandler.cpp:8:
/home/enigma/waifu2x/waifu2x-converter-cpp-master/src/CLlib.h:13:23: fatal error: CL/opencl.h: No such file or directory
#include <CL/opencl.h>
^
compilation terminated.

It seems that CMake did not assign the correct env vars. My CMake output is :
-- The C compiler identification is GNU 4.8.3
-- The CXX compiler identification is GNU 4.8.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/enigma/waifu2x/waifu2x-converter-cpp-master

I have compiled an OpenCV 3.1 and install but it seems that the CMake can not find it.

hello, I am compiling your program, but I have a preblem.

hello, I am compiling your program, but I have a preblem.

There are some strange lines to me such as

static const char prog[] =
#include "modelHandler_OpenCL.cl.h"
;

static const char prog20[] =
#include "modelHandler_CUDA.ptx20.h"
;
static const char prog30[] =
#include "modelHandler_CUDA.ptx30.h"
;

When I compile, I got error because of the lines.
What happen?
It is wrong on my C++ background.
How did you use well?

Arch PKGBUILD

This isn't an issue, I am just making you aware that I have made a PKGBUILD for Arch Linux. I have tested it and it works well on either Intel or AMD systems. Unfortunately I do not have an NVIDIA Card so I can't test that.

https://aur.archlinux.org/packages/waifu2x-git/

This provides an easy way for Arch users to install waifu2x. It handles all building (here is a sample output):

==> Making package: waifu2x-git r250.ca65c93-3 (Wed Sep 23 14:11:48 PHT 2015)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Cloning waifu2x-converter-cpp git repo...
Cloning into bare repository '/tmp/waifu2x-git/waifu2x-converter-cpp'...
remote: Counting objects: 1578, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 1578 (delta 2), reused 0 (delta 0), pack-reused 1565
Receiving objects: 100% (1578/1578), 21.62 MiB | 1.15 MiB/s, done.
Resolving deltas: 100% (1123/1123), done.
Checking connectivity... done.
==> Validating source files with md5sums...
    waifu2x-converter-cpp ... Skipped
==> Extracting sources...
  -> Creating working copy of waifu2x-converter-cpp git repo...
Cloning into 'waifu2x-converter-cpp'...
done.
==> Starting pkgver()...
==> Starting prepare()...
patching file appendix/waifu2x-nocuda/lib/settings.lua
patching file appendix/waifu2x-nocuda/waifu2x.lua
patching file src/main.cpp
==> Starting build()...
-- The C compiler identification is GNU 5.2.0
-- The CXX compiler identification is GNU 5.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing:  CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) 
CMake Warning at CMakeLists.txt:20 (message):
  cuda not found.  disabled.


-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/waifu2x-git/src/waifu2x-converter-cpp
Scanning dependencies of target conv
[  5%] Building C object CMakeFiles/conv.dir/conv.c.o
[ 10%] Linking C executable conv
[ 10%] Built target conv
Scanning dependencies of target gensrcs
[ 15%] Generating modelHandler_OpenCL.cl.h
[ 15%] Built target gensrcs
Scanning dependencies of target w2xc
[ 21%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler.cpp.o                                                                   
[ 26%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_fma.cpp.o                                                               
[ 31%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_avx.cpp.o                                                               
[ 36%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_sse.cpp.o                                                               
[ 42%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_OpenCL.cpp.o                                                            
[ 47%] Building CXX object CMakeFiles/w2xc.dir/src/convertRoutine.cpp.o                                                                 
[ 52%] Building CXX object CMakeFiles/w2xc.dir/src/threadPool.cpp.o
[ 57%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_CUDA.cpp.o                                                              
[ 63%] Building CXX object CMakeFiles/w2xc.dir/src/w2xconv.cpp.o
[ 68%] Building CXX object CMakeFiles/w2xc.dir/src/common.cpp.o
[ 73%] Building CXX object CMakeFiles/w2xc.dir/src/Env.cpp.o
[ 78%] Linking CXX shared library libw2xc.so
[ 78%] Built target w2xc
Scanning dependencies of target runtest
Scanning dependencies of target waifu2x-converter-cpp
[ 84%] Building C object CMakeFiles/runtest.dir/w32-apps/runtest.c.o
[ 89%] Building CXX object CMakeFiles/waifu2x-converter-cpp.dir/src/main.cpp.o                                                          
[ 94%] Linking C executable runtest
[ 94%] Built target runtest
[100%] Linking CXX executable waifu2x-converter-cpp
[100%] Built target waifu2x-converter-cpp
==> Starting check()...
==> Running Waifu2x's test suite. Depending on your processor and GPU, this may take a while.
start process block (0,0) ...
Iteration #1(1->32)...(3.01475[ms], 4.66111[GFLOPS], 1.06817[GB/s])
Iteration #2(32->32)...(13.9452[ms], 32.2453[GFLOPS], 0.447852[GB/s])
Iteration #3(32->64)...(19.8823[ms], 45.2329[GFLOPS], 0.471176[GB/s])
Iteration #4(64->64)...(37.985[ms], 47.352[GFLOPS], 0.328834[GB/s])
Iteration #5(64->128)...(108.265[ms], 33.2272[GFLOPS], 0.173058[GB/s])
Iteration #6(128->128)...(137.966[ms], 52.1483[GFLOPS], 0.181071[GB/s])
Iteration #7(128->1)...(1.73939[ms], 32.3151[GFLOPS], 7.23722[GB/s])
total : 0.323218[sec], 43.3451[GFLOPS]
start scaling
#1 2x scaling...
start process block (0,0) ...
Iteration #1(1->32)...(8.2959[ms], 6.15139[GFLOPS], 1.40969[GB/s])
Iteration #2(32->32)...(41.4538[ms], 39.3933[GFLOPS], 0.547129[GB/s])
Iteration #3(32->64)...(76.7866[ms], 42.5335[GFLOPS], 0.443057[GB/s])
Iteration #4(64->64)...(173.087[ms], 37.7382[GFLOPS], 0.262071[GB/s])
Iteration #5(64->128)...(267.79[ms], 48.7846[GFLOPS], 0.254086[GB/s])
Iteration #6(128->128)...(471.417[ms], 55.4244[GFLOPS], 0.192446[GB/s])
Iteration #7(128->1)...(5.88946[ms], 34.6594[GFLOPS], 7.76227[GB/s])
total : 1.04507[sec], 48.6841[GFLOPS]
start process block (0,0) ...
Iteration #1(1->32)...(5.31938[ms], 2.64168[GFLOPS], 0.605384[GB/s])
Iteration #2(32->32)...(10.3391[ms], 43.4921[GFLOPS], 0.604057[GB/s])
Iteration #3(32->64)...(18.1773[ms], 49.4758[GFLOPS], 0.515373[GB/s])
Iteration #4(64->64)...(35.922[ms], 50.0714[GFLOPS], 0.347718[GB/s])
Iteration #5(64->128)...(72.7572[ms], 49.4431[GFLOPS], 0.257516[GB/s])
Iteration #6(128->128)...(143.634[ms], 50.0902[GFLOPS], 0.173924[GB/s])
Iteration #7(128->1)...(1.86864[ms], 30.0798[GFLOPS], 6.73663[GB/s])
total : 0.288365[sec], 48.5841[GFLOPS]
start scaling
#1 2x scaling...
start process block (0,0) ...
Iteration #1(1->32)...(8.26065[ms], 6.17764[GFLOPS], 1.41571[GB/s])
Iteration #2(32->32)...(35.0002[ms], 46.6569[GFLOPS], 0.648013[GB/s])
Iteration #3(32->64)...(62.6[ms], 52.1725[GFLOPS], 0.543464[GB/s])
Iteration #4(64->64)...(120.463[ms], 54.2243[GFLOPS], 0.376558[GB/s])
Iteration #5(64->128)...(244.34[ms], 53.4665[GFLOPS], 0.278471[GB/s])
Iteration #6(128->128)...(469.409[ms], 55.6615[GFLOPS], 0.193269[GB/s])
Iteration #7(128->1)...(6.2351[ms], 32.7381[GFLOPS], 7.33197[GB/s])
total : 0.946639[sec], 53.7462[GFLOPS]
start process block (0,0) ...
Iteration #1(1->32)...(4.2722[ms], 3.28919[GFLOPS], 0.753774[GB/s])
Iteration #2(32->32)...(10.487[ms], 42.8785[GFLOPS], 0.595535[GB/s])
Iteration #3(32->64)...(19.3279[ms], 46.5304[GFLOPS], 0.484692[GB/s])
Iteration #4(64->64)...(35.1552[ms], 51.1637[GFLOPS], 0.355303[GB/s])
Iteration #5(64->128)...(72.76[ms], 49.4411[GFLOPS], 0.257506[GB/s])
Iteration #6(128->128)...(147.638[ms], 48.7319[GFLOPS], 0.169208[GB/s])
Iteration #7(128->1)...(2.39283[ms], 23.4903[GFLOPS], 5.26085[GB/s])
total : 0.292373[sec], 47.918[GFLOPS]
==> Entering fakeroot environment...
==> Starting package()...
==> Waifu2x will be installed as /usr/bin/waifu2x. It has no manpage, reading /usr/bin/waifu2x -h is probably a good idea.
==> Tidying install...
  -> Purging unwanted files...
  -> Removing libtool files...
  -> Removing static library files...
  -> Compressing man and info pages...
  -> Stripping unneeded symbols from binaries and libraries...
==> Creating package "waifu2x-git"...
  -> Generating .PKGINFO file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: waifu2x-git r250.ca65c93-3 (Wed Sep 23 14:12:49 PHT 2015)

Then pacman -U waifu2x-git-r250.ca65c93-3-x86_64.pkg.tar.xz:

loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (1) waifu2x-git-r250.ca65c93-3

Total Installed Size:  16.22 MiB

:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring                     [##########] 100%
(1/1) checking package integrity                   [##########] 100%
(1/1) loading package files                        [##########] 100%
(1/1) checking for file conflicts                  [##########] 100%
(1/1) checking available disk space                [##########] 100%
(1/1) installing waifu2x-git                       [##########] 100%
Optional dependencies for waifu2x-git
    cuda: Significantly speeds up operations, but only works with
    NVIDIA GPU
    libdc1394: IEEE1394 capturing support [installed]

Hope you enjoy and this helps someone. :)

Segfaults when using OpenCL

When using any OpenCL backend, waifu2x (f89dd61) will segfault.

My platforms are these:

   0: AMD CEDAR (DRM 2.45.0 / 4.7.7-1-ck, LLVM 3.8.1)(OpenCL    ): num_core=2
   1:         Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz(AVX       ): num_core=8
   2:         Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz(OpenCL    ): num_core=8

When invoking waifu2x --processor $i -i input.jpg -o output.jpg (where i={0,2}), the process segfaults.

Backtrace for the OpenCL mesa (12.0.3) backend:

Thread 1 "waifu2x-convert" received signal SIGSEGV, Segmentation fault.
#0  0x00007ffff3be3fbe in fwrite () from /usr/lib/libc.so.6
#1  0x00007ffff79a2ea4 in w2xc::initOpenCL (c=0x6ad6e0, env=0x6ad750, proc=0x6f4e70)
    at /tmp/makepkg/waifu2x-converter-cpp-git/src/waifu2x-converter-cpp/src/modelHandler_OpenCL.cpp:398
#2  0x00007ffff79aa29e in w2xconv_init_with_processor (processor_idx=0, nJob=8, 
    enable_log=1)
    at /tmp/makepkg/waifu2x-converter-cpp-git/src/waifu2x-converter-cpp/src/w2xconv.cpp:379
#3  0x000000000041ab35 in main (argc=7, argv=0x7fffffffdcf8)
    at /tmp/makepkg/waifu2x-converter-cpp-git/src/waifu2x-converter-cpp/src/main.cpp:187

Backtrace for the Intel OpenCL (runtime 16.1.1) backend:

Thread 1 "waifu2x-convert" received signal SIGSEGV, Segmentation fault.
#0  0x0000000000000000 in ?? ()
#1  0x00007fffe7b02007 in ?? () from /opt/intel/opencl-runtime/lib64/libcpu_device.so
#2  0x00007fffe7b0c33b in ?? () from /opt/intel/opencl-runtime/lib64/libcpu_device.so
#3  0x00007fffe7b0d826 in clDevCreateDeviceInstance () from /opt/intel/opencl-runtime/lib64/libcpu_device.so
#4  0x00007fffe84b7fa5 in ?? () from /opt/intel/opencl-runtime/lib64/libintelocl.so
#5  0x00007fffe8479b69 in ?? () from /opt/intel/opencl-runtime/lib64/libintelocl.so
#6  0x00007fffe84569a2 in ?? () from /opt/intel/opencl-runtime/lib64/libintelocl.so
#7  0x00007fffe843bb74 in clCreateContext () from /opt/intel/opencl-runtime/lib64/libintelocl.so
#8  0x00007fffee87a060 in clCreateContext () from /usr/lib/libOpenCL.so.1
#9  0x00007ffff79a27ec in w2xc::initOpenCL (c=0x6ad6e0, env=0x6ad750, proc=0x6f4ec0) at /tmp/makepkg/waifu2x-converter-cpp-git/src/waifu2x-converter-cpp/src/modelHandler_OpenCL.cpp:209
#10 0x00007ffff79aa29e in w2xconv_init_with_processor (processor_idx=2, nJob=8, enable_log=1) at /tmp/makepkg/waifu2x-converter-cpp-git/src/waifu2x-converter-cpp/src/w2xconv.cpp:379
#11 0x000000000041ab35 in main (argc=7, argv=0x7fffffffdcf8) at /tmp/makepkg/waifu2x-converter-cpp-git/src/waifu2x-converter-cpp/src/main.cpp:187

w2xconv_apply_filter_y crashes

Hi tanakamura,

When I use the prebuilt binary of both 1101 and 1130, my program crashes when invoking w2xconv_apply_filter_y. When I use the 1019 binary, the crash doesn't occur. Could you please provide a debug built with pdb file if you use MSVC to compile it? Thanks.

Best regards,
HolyWu

Add a parameter to choose different GPU on system

Hi tanakamura,

Could you please add a parameter to let users be able to specify the device to use, if there are two graphics cards installed on the computer? Thank you very much.

Best regards,
HolyWu

Is OpenCL not working for NVIDIA GPU?

C:\waifu2x-converter_x86_0726>waifu2x-converter_x86.exe --block_size 1024 --force-OpenCL -m scale -o bar.png -i foo.png
OpenCL: GeForce GTX 660
start scaling
#1 2x scaling...
start process block (0,0) ...
Iteration #1(3->32)...(101.097[ms], 17.0476[GFLOPS], 1.38117[GB/s])
Iteration #2(32->32)...wait ndrange error : -9999

I know that CUDA may be preferred on NVIDIA GPU, but I just want to compare the speed difference between them. http://pastebin.com/c99Sxi5v is the content of the generated GeForce GTX 660.bin file. Thank you very much.

Can you (or anyone) give me proper compilation instructions?

I tried native and cross compilation:

Native fails with:

2>w2xcr.obj : error LNK2019: unresolved external symbol __imp_w2xconv_convert_file referenced in function proc_thread
2>*****\Release\w2xcr.exe : fatal error LNK1120: 1 unresolved externals

Cross compilation fails with:

[ 89%] Linking C executable w2xcr.exe
CMakeFiles/w2xcr.dir/objects.a(w2xcr.c.obj):w2xcr.c:(.text+0xe1a): undefined reference to `__imp_w2xconv_convert_file'
collect2: error: ld returned 1 exit status
CMakeFiles/w2xcr.dir/build.make:116: recipe for target 'w2xcr.exe' failed

Compilation failed on macOS

Hi, I found this error when I compiled it on macOS:

tmp/waifu2x-converter-cpp/src/common.cpp:201:13: error: no member named
      'st_mtim' in 'stat'
        if (src_st.st_mtim.tv_sec > dst_st.st_mtim.tv_sec) {
            ~~~~~~ ^
/tmp/waifu2x-converter-cpp/src/common.cpp:201:37: error: no member named
      'st_mtim' in 'stat'
        if (src_st.st_mtim.tv_sec > dst_st.st_mtim.tv_sec) {
                                    ~~~~~~ ^
/tmp/waifu2x-converter-cpp/src/common.cpp:205:13: error: no member named
      'st_mtim' in 'stat'
        if (src_st.st_mtim.tv_nsec > dst_st.st_mtim.tv_nsec) {
            ~~~~~~ ^
/tmp/waifu2x-converter-cpp/src/common.cpp:205:38: error: no member named
      'st_mtim' in 'stat'
        if (src_st.st_mtim.tv_nsec > dst_st.st_mtim.tv_nsec) {
                                     ~~~~~~ ^
4 errors generated.

I think it is a problem about the difference of stat library's implementation in macOS. So I searched for the manual, and changing it to st_mtime will allow it to compile.
So can we make some check of the platform? Thanks.

OpenCL Segmentation fault on AMD Kaveri APU (Linux)

SOLVED MYSELF (original Issue is below the Line):

in modelHandler_OpenCL.cpp:
std::string bin_path = std::string(self_path) + "/" + &dev_name[0] + ".bin";

Can create illegal filenames like:
AMD KAVERI (DRM 2.46.0 / 4.8.0-30-generic, LLVM 3.8.1).bin

By cleaning bin_path with a function like: http://codereview.stackexchange.com/a/285

I got it to work just fine:

$ ./waifu2x-converter-cpp --force-OpenCL --scale_ratio 2 -i test.jpg
OpenCL: AMD KAVERI (DRM 2.46.0 / 4.8.0-30-generic, LLVM 3.8.1)
start process block (0,0) ...

Bin file is now: AMD_KAVERI_(DRM_2.46.0___4.8.0-30-generic__LLVM_3.8.1).bin

Fixed Code like:

void removeForbiddenChar(std::string* s)
{
	std::string::iterator it;
	std::string illegalChars = "\\/:?\"<>|, ";
	for (it = s->begin() ; it < s->end() ; ++it){
		bool found = illegalChars.find(*it) != std::string::npos;
		if(found){
			*it = '_';
		}
	}
}
....
std::string dev_nameStr = &dev_name[0];
removeForbiddenChar(&dev_nameStr);
std::string bin_path = std::string(self_path) + "/" + dev_nameStr + ".bin";
....

Original issue:

I barely know how to debug on linux so all I can provide is:
Compiled with OpenCV 3.1 Stable (3.0 Stable and 3.0 RC1 all produce the same error)

Thread 1 "waifu2x-convert" received signal SIGSEGV, Segmentation fault.
__GI__IO_fwrite (buf=0x555555bbe3a0, size=1, count=118308, fp=0x0) at iofwrite.c:37
37      iofwrite.c: No such file or directory.
(gdb) Quit
(gdb) backtrace
#0  __GI__IO_fwrite (buf=0x555556cb6640, size=1, count=118308, fp=0x0) at iofwrite.c:37
#1  0x00007ffff7ba735c in w2xc::initOpenCL (c=0x55555581f620, env=0x55555585e9d0, proc=0x555555824be0) at /sources/waifu2x-converter-cpp/src/modelHandler_OpenCL.cpp:398
#2  0x00007ffff7baef47 in w2xconv_init_with_processor (processor_idx=0, nJob=4, enable_log=1) at /sources/waifu2x-converter-cpp/src/w2xconv.cpp:379
#3  0x00007ffff7baee97 in w2xconv_init (gpu=W2XCONV_GPU_FORCE_OPENCL, nJob=0, enable_log=1) at /sources/waifu2x-converter-cpp/src/w2xconv.cpp:353
#4  0x00005555555702bf in main (argc=6, argv=0x7fffffffe4c8) at /sources/waifu2x-converter-cpp/src/main.cpp:190

Seems to crash at

....
#ifdef GENERATE_BINARY
        if (!bin_avaiable) {
.....
while (rem) {
                        size_t wsz = fwrite(p, 1, rem, fp); // <---Crash
.,...

Any idea?

max20091 and me forked and improved this.

I improved upon max20091's fork and added a proper BUILDING.md.

If you have issues compiling on VS2015 and or AMD GPUs,
see my fork https://github.com/DeadSix27/waifu2x-converter-cpp

I also fixed the CL binary file handling and improved the cmake script.

BUILDING.md has a guide for OpenCV 3.2 and VS2015 on 64 bit CPU.
As well as Ubuntu 16.10-amd64!

I will possibly add better unicode support too, see fork-issues "Todo list"

Binary name should be waifu2x

OK, so let's discuss this...

In my downstream package, I rename the binary waifu2x-converter-cpp to waifu2x.

Why?

  • I think waifu2x-converter-cpp is too long.
  • C++ has nothing to do with what the binary actually does. Bash isn't named "CBash", and while the C Python implementation is internally called CPython, its binary is just python.
  • I don't think converter means anything either. waifu2x is not an image converter, it's a rescaler/denoising program.

What do you guys think?

segfault when use cuda 8

└───╼  waifu2x-converter-cpp --list-processor
Violación de segmento (`core' generado)
└───╼  coredumpctl info 22842
           PID: 22842 (waifu2x-convert)
           UID: 1000 (sl1pkn07)
           GID: 100 (users)
        Signal: 11 (SEGV)
     Timestamp: sáb 2016-08-27 14:51:18 CEST (2min 9s ago)
  Command Line: waifu2x-converter-cpp --list-processor
    Executable: /usr/bin/waifu2x-converter-cpp
 Control Group: /user.slice/user-1000.slice/session-c1.scope
          Unit: session-c1.scope
         Slice: user-1000.slice
       Session: c1
     Owner UID: 1000 (sl1pkn07)
       Boot ID: c9b54356c0f7498d9d2e236135ba09a0
    Machine ID: c20ee0c57658685bfedf50384b0e3ec0
      Hostname: sL1pKn07
      Coredump: /var/lib/systemd/coredump/core.waifu2x-convert.1000.c9b54356c0f7498d9d2e236135ba09a0.22842.1472302278000000000000.lz4
       Message: Process 22842 (waifu2x-convert) of user 1000 dumped core.

                Stack trace of thread 22842:
                #0  0x00007f9cbc859ad0 pthread_mutex_lock (libpthread.so.0)
                #1  0x00007f9cb6d940e8 n/a (libcuda.so.1)
                #2  0x00007f9cb6e49f91 n/a (libcuda.so.1)
                #3  0x00007f9cb6e4a105 n/a (libcuda.so.1)
                #4  0x00007f9cb6d99e24 n/a (libcuda.so.1)
                #5  0x00007f9cb6d9b677 n/a (libcuda.so.1)
                #6  0x00007f9cb6d6f846 n/a (libcuda.so.1)
                #7  0x00007f9cb6dbb79d cuInit (libcuda.so.1)
                #8  0x00007f9cc007f96e _ZN4w2xc14initCUDAGlobalEPSt6vectorI16W2XConvProcessorSaIS1_EE (libw2xc.so)
                #9  0x00007f9cc008bc24 n/a (libw2xc.so)
                #10 0x00007f9cbc85e6f9 __pthread_once_slow (libpthread.so.0)
                #11 0x00007f9cc0081337 w2xconv_get_processor_list (libw2xc.so)
                #12 0x000000000040a350 n/a (waifu2x-converter-cpp)
                #13 0x0000000000407e42 main (waifu2x-converter-cpp)
                #14 0x00007f9cbf73c291 __libc_start_main (libc.so.6)
                #15 0x000000000040a25a _start (waifu2x-converter-cpp)

                Stack trace of thread 22843:
                #0  0x00007f9cbf805cd8 accept4 (libc.so.6)
                #1  0x00007f9cb81d86a6 n/a (libnvidia-opencl.so.1)
                #2  0x00007f9cb81cc4ad n/a (libnvidia-opencl.so.1)
                #3  0x00007f9cb81d9098 n/a (libnvidia-opencl.so.1)
                #4  0x00007f9cbc857454 start_thread (libpthread.so.0)
                #5  0x00007f9cbf8047df __clone (libc.so.6)

nvidia drivers 370.23 over GTX 770

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.