Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Train error #5

Open
FirokOtaku opened this issue Sep 22, 2023 · 0 comments
Open

Train error #5

FirokOtaku opened this issue Sep 22, 2023 · 0 comments

Comments

@FirokOtaku
Copy link

Reproduce steps:

conda create -n deep-hawkeye python=3.6
conda activate deep-hawkeye
pip install opencv-python scipy

# pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
# command above is broken, used following instead ( provided by PyTorch website: https://pytorch.org/get-started/previous-versions/ )
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge

# conda install -c pytorch faiss-gpu cudatoolkit=10.2
# command above is broken too, used following instead ( provided by Anaconda package search results: https://anaconda.org/conda-forge/faiss-gpu )
conda install -c conda-forge faiss-gpu

# try to start training
python demo_train.py -d "./workdir/demo_data/grid/normal_data" -c "grid" --batch_size=64 --weight_path="./workdir/wide_r50_2.pth" --normal_feature_save_path="./workdir/export_pth" --model_device="cuda:0" --max_cluster_image_num=1000 --index_build_device=-1

Then comes a TypeError:

Traceback (most recent call last):
  File "demo_train.py", line 42, in <module>
    gen_lib(train_img_path, cls)
  File "demo_train.py", line 33, in __call__
    self.train_model.train()
  File "T:\Projects\DeepHawkeye\src\train.py", line 105, in train
    np.arange(0, seg_batch_size),
  File "C:\Users\firok\.conda\envs\deep-hawkeye\lib\site-packages\faiss\__init__.py", line 112, in replacement_add_with_ids
    self.add_with_ids_c(n, swig_ptr(x), swig_ptr(ids))
  File "C:\Users\firok\.conda\envs\deep-hawkeye\lib\site-packages\faiss\swigfaiss_avx2.py", line 3898, in add_with_ids
    return _swigfaiss_avx2.IndexIVFPQ_add_with_ids(self, n, x, xids)
TypeError: Wrong number or type of arguments for overloaded function 'IndexIVFPQ_add_with_ids'.
  Possible C/C++ prototypes are:
    faiss::IndexIVFPQ::add_with_ids(faiss::Index::idx_t,float const *,faiss::Index::idx_t const *)
    faiss::IndexIVFPQ::add_with_ids(faiss::Index::idx_t,float const *)

Environment:

Win x64 22H2

conda list -n deep-hawkeye

# Name                    Version                   Build  Channel
blas                      2.118                       mkl    conda-forge
blas-devel                3.9.0              18_win64_mkl    conda-forge
bzip2                     1.0.8                he774522_0
ca-certificates           2023.7.22            h56e8100_0    conda-forge
cudatoolkit               11.1.1              heb2d755_10    conda-forge
dataclasses               0.8                pyh787bdff_2    conda-forge
faiss                     1.7.0           py36cuda111hfcdb8f5_8_cuda    conda-forge
faiss-gpu                 1.7.0                h278398d_8    conda-forge
freetype                  2.7                      vc14_0    conda-forge
intel-openmp              2023.2.0         h57928b3_49502    conda-forge
jpeg                      9b                   hb83a4c4_2
libblas                   3.9.0              18_win64_mkl    conda-forge
libcblas                  3.9.0              18_win64_mkl    conda-forge
libfaiss                  1.7.0           cuda111hbde4fbc_8_cuda    conda-forge
libfaiss-avx2             1.7.0           cuda111h1234567_8_cuda    conda-forge
libffi                    3.4.4                hd77b12b_0
liblapack                 3.9.0              18_win64_mkl    conda-forge
liblapacke                3.9.0              18_win64_mkl    conda-forge
libpng                    1.6.37               h1d00b33_2    conda-forge
libtiff                   4.0.9                hf1753bf_1    conda-forge
libuv                     1.44.2               h8ffe710_0    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    conda-forge
m2w64-gcc-libs            5.3.0                         7    conda-forge
m2w64-gcc-libs-core       5.3.0                         7    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    conda-forge
mkl                       2022.1.0           h6a75c08_874    conda-forge
mkl-devel                 2022.1.0           h57928b3_875    conda-forge
mkl-include               2022.1.0           h6a75c08_874    conda-forge
msys2-conda-epoch         20160418                      1    conda-forge
ninja                     1.11.0               h2d74725_0    conda-forge
numpy                     1.26.0                   pypi_0    pypi
olefile                   0.46               pyh9f0ad1d_1    conda-forge
opencv-python             4.8.0.76                 pypi_0    pypi
openssl                   3.1.3                hcfcfb64_0    conda-forge
pillow                    4.2.1                    py36_0    conda-forge
pip                       21.3.1             pyhd8ed1ab_0    conda-forge
python                    3.6.15          h39d44d4_0_cpython    conda-forge
python_abi                3.6                     2_cp36m    conda-forge
pytorch                   1.8.0           py3.6_cuda11.1_cudnn8_0    pytorch
scipy                     1.11.2                   pypi_0    pypi
setuptools                58.0.4           py36ha15d459_2    conda-forge
sqlite                    3.41.2               h2bbff1b_0
tbb                       2021.5.0             h2d74725_1    conda-forge
tk                        8.6.12               h2bbff1b_0
torchaudio                0.8.0                      py36    pytorch
torchvision               0.9.0                py36_cu111    pytorch
typing_extensions         4.1.1              pyha770c72_0    conda-forge
tzdata                    2023c                h04d1e81_0
ucrt                      10.0.22621.0         h57928b3_0    conda-forge
vc                        14.2                 h21ff451_1
vc14_runtime              14.36.32532         hdcecf7f_17    conda-forge
vs2015_runtime            14.36.32532         h05e6639_17    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
xz                        5.4.2                h8cc25b3_0
zlib                      1.2.13               h8cc25b3_0

# BTW, parameter type conversion code missed several type declarations and would cause TypeError.
# Here is the fix
def get_train_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('-d','--total_img_paths', type=str, default=None)
    parser.add_argument('-c','--category', type=str, default=None, help='category of sample')
    parser.add_argument('--batch_size', default=64, type=int)
    parser.add_argument('--embedding_layers', choices=['1_2', '2_3'], default='2_3')
    parser.add_argument('--input_size', default=(224, 224))
    parser.add_argument('--weight_path', default='./weights/wide_r50_2.pth')
    parser.add_argument('--normal_feature_save_path', default=f"./index_lib")
    parser.add_argument('--model_device', default="cuda:0")
    parser.add_argument('--max_cluster_image_num', default=1000, type=int, help='depend on CPU memory, more than total images number')
    parser.add_argument('--index_build_device', default=-1, type=int, help='CPU:-1 ,GPU number eg: 0, 1, 2 (only on Linux)')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant