[GH-ISSUE #81] errors in finetuning the clip using my own datasets #75

Closed
opened 2026-10-31 21:10:30 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @lycutter on GitHub (Apr 7, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/81

Traceback (most recent call last):
File "E:\PyCharm Community Edition 2020.1.4\plugins\python-ce\helpers\pydev\pydevd.py", line 1438, in exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "E:\PyCharm Community Edition 2020.1.4\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "G:/PythonWorkplace/ImageCLEF2021/train_clip.py", line 207, in
loss.backward(create_graph=True)
File "E:\Anaconda\envs\clip\lib\site-packages\torch\tensor.py", line 221, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "E:\Anaconda\envs\clip\lib\site-packages\torch\autograd_init
.py", line 132, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: default_program(58): error: identifier "aten_mul_flat__1" is undefined

default_program(59): error: no operator "=" matches these operands
operand types are: half = float

2 errors detected in the compilation of "default_program".

nvrtc compilation failed:

#define NAN __int_as_float(0x7fffffff)
#define POS_INFINITY __int_as_float(0x7f800000)
#define NEG_INFINITY __int_as_float(0xff800000)

template
device T maximum(T a, T b) {
return isnan(a) ? a : (a > b ? a : b);
}

template
device T minimum(T a, T b) {
return isnan(a) ? a : (a < b ? a : b);
}

#define __HALF_TO_US(var) *(reinterpret_cast<unsigned short *>(&(var)))
#define __HALF_TO_CUS(var) *(reinterpret_cast<const unsigned short *>(&(var)))
#if defined(__cplusplus)
struct align(2) __half {
host device __half() { }

protected:
unsigned short __x;
};

/* All intrinsic functions are only available to nvcc compilers /
#if defined(CUDACC)
/
Definitions of intrinsics */
device __half __float2half(const float f) {
__half val;
asm("{ cvt.rn.f16.f32 %0, %1;}\n" : "=h"(__HALF_TO_US(val)) : "f"(f));
return val;
}

__device__ float __half2float(const __half h) {
  float val;
  asm("{  cvt.f32.f16 %0, %1;}\n" : "=f"(val) : "h"(__HALF_TO_CUS(h)));
  return val;
}

#endif /* defined(CUDACC) /
#endif /
defined(__cplusplus) */
#undef __HALF_TO_US
#undef __HALF_TO_CUS

typedef __half half;

extern "C" global
void func_25(half* t0, half* t1, half* t2, half* t3, half* aten_add_flat, half* aten_mul_flat, half* aten_add_flat_1, half* aten_mul_flat_1) {
{
float v = __half2float(t0[512 * blockIdx.x + threadIdx.x]);
aten_add_flat_1[512 * blockIdx.x + threadIdx.x] = _float2half((0.f - v) + 1.f);
float t1
= _half2float(t1[512 * blockIdx.x + threadIdx.x]);
float t2
= _half2float(t2[512 * blockIdx.x + threadIdx.x]);
float aten_mul_flat
= _half2float(aten_mul_flat_1[512 * blockIdx.x + threadIdx.x]);
aten_mul_flat__1 = float2half(t1 * t2);
aten_mul_flat_1[512 * blockIdx.x + threadIdx.x] = aten_mul_flat
;
float v_1 = __half2float(t0[512 * blockIdx.x + threadIdx.x]);
float v_2 = __half2float(t0[512 * blockIdx.x + threadIdx.x]);
aten_mul_flat[512 * blockIdx.x + threadIdx.x] = __float2half(((0.f - v_1) + 1.f) * v_2);
float v_3 = __half2float(t3[512 * blockIdx.x + threadIdx.x]);
float v_4 = __half2float(t0[512 * blockIdx.x + threadIdx.x]);
float v_5 = _half2float(t0[512 * blockIdx.x + threadIdx.x]);
aten_add_flat[512 * blockIdx.x + threadIdx.x] = float2half(t1 * v_3 + ((((0.f - v_4) + 1.f) * v_5) * (t1 * t2
)) * 1.702000021934509f);
}
}

Originally created by @lycutter on GitHub (Apr 7, 2021). Original GitHub issue: https://github.com/openai/CLIP/issues/81 Traceback (most recent call last): File "E:\PyCharm Community Edition 2020.1.4\plugins\python-ce\helpers\pydev\pydevd.py", line 1438, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "E:\PyCharm Community Edition 2020.1.4\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "G:/PythonWorkplace/ImageCLEF2021/train_clip.py", line 207, in <module> loss.backward(create_graph=True) File "E:\Anaconda\envs\clip\lib\site-packages\torch\tensor.py", line 221, in backward torch.autograd.backward(self, gradient, retain_graph, create_graph) File "E:\Anaconda\envs\clip\lib\site-packages\torch\autograd\__init__.py", line 132, in backward allow_unreachable=True) # allow_unreachable flag RuntimeError: default_program(58): error: identifier "aten_mul_flat__1" is undefined default_program(59): error: no operator "=" matches these operands operand types are: half = float 2 errors detected in the compilation of "default_program". nvrtc compilation failed: #define NAN __int_as_float(0x7fffffff) #define POS_INFINITY __int_as_float(0x7f800000) #define NEG_INFINITY __int_as_float(0xff800000) template<typename T> __device__ T maximum(T a, T b) { return isnan(a) ? a : (a > b ? a : b); } template<typename T> __device__ T minimum(T a, T b) { return isnan(a) ? a : (a < b ? a : b); } #define __HALF_TO_US(var) *(reinterpret_cast<unsigned short *>(&(var))) #define __HALF_TO_CUS(var) *(reinterpret_cast<const unsigned short *>(&(var))) #if defined(__cplusplus) struct __align__(2) __half { __host__ __device__ __half() { } protected: unsigned short __x; }; /* All intrinsic functions are only available to nvcc compilers */ #if defined(__CUDACC__) /* Definitions of intrinsics */ __device__ __half __float2half(const float f) { __half val; asm("{ cvt.rn.f16.f32 %0, %1;}\n" : "=h"(__HALF_TO_US(val)) : "f"(f)); return val; } __device__ float __half2float(const __half h) { float val; asm("{ cvt.f32.f16 %0, %1;}\n" : "=f"(val) : "h"(__HALF_TO_CUS(h))); return val; } #endif /* defined(__CUDACC__) */ #endif /* defined(__cplusplus) */ #undef __HALF_TO_US #undef __HALF_TO_CUS typedef __half half; extern "C" __global__ void func_25(half* t0, half* t1, half* t2, half* t3, half* aten_add_flat, half* aten_mul_flat, half* aten_add_flat_1, half* aten_mul_flat_1) { { float v = __half2float(t0[512 * blockIdx.x + threadIdx.x]); aten_add_flat_1[512 * blockIdx.x + threadIdx.x] = __float2half((0.f - v) + 1.f); float t1_ = __half2float(t1[512 * blockIdx.x + threadIdx.x]); float t2_ = __half2float(t2[512 * blockIdx.x + threadIdx.x]); float aten_mul_flat_ = __half2float(aten_mul_flat_1[512 * blockIdx.x + threadIdx.x]); aten_mul_flat__1 = __float2half(t1_ * t2_); aten_mul_flat_1[512 * blockIdx.x + threadIdx.x] = aten_mul_flat_; float v_1 = __half2float(t0[512 * blockIdx.x + threadIdx.x]); float v_2 = __half2float(t0[512 * blockIdx.x + threadIdx.x]); aten_mul_flat[512 * blockIdx.x + threadIdx.x] = __float2half(((0.f - v_1) + 1.f) * v_2); float v_3 = __half2float(t3[512 * blockIdx.x + threadIdx.x]); float v_4 = __half2float(t0[512 * blockIdx.x + threadIdx.x]); float v_5 = __half2float(t0[512 * blockIdx.x + threadIdx.x]); aten_add_flat[512 * blockIdx.x + threadIdx.x] = __float2half(t1_ * v_3 + ((((0.f - v_4) + 1.f) * v_5) * (t1_ * t2_)) * 1.702000021934509f); } }
Author
Owner

@vinson2233 commented on GitHub (Apr 8, 2021):

It will be much helpful if you can show your training code, and point out which line is giving the error.

Is there any reason to put create_graph=True in the backward? I don't use that when training the CLIP and it works fine for me.

<!-- gh-comment-id:815477098 --> @vinson2233 commented on GitHub (Apr 8, 2021): It will be much helpful if you can show your training code, and point out which line is giving the error. Is there any reason to put `create_graph=True` in the backward? I don't use that when training the CLIP and it works fine for me.
Author
Owner

@lycutter commented on GitHub (Apr 8, 2021):

It will be much helpful if you can show your training code, and point out which line is giving the error.

Is there any reason to put create_graph=True in the backward? I don't use that when training the CLIP and it works fine for me.

It works, thanks!

<!-- gh-comment-id:815565468 --> @lycutter commented on GitHub (Apr 8, 2021): > It will be much helpful if you can show your training code, and point out which line is giving the error. > > Is there any reason to put `create_graph=True` in the backward? I don't use that when training the CLIP and it works fine for me. It works, thanks!
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openai/CLIP#75
No description provided.