jiebi/CodeConvo huggingface dataset:
Code change:
from collections import defaultdict import torch <del> try: FileNotFoundError except NameError: # py2.7 FileNotFoundError = IOError </del> <ins> from torch._six import FileNotFoundError </ins> class range(object):

Related discussion:
text: Traceback (most recent call last): File "", line 322, in &lt;moduleroislabel = fasterRCNN(imdata, iminfo, gtboxes, numboxes) File "/usr/local/lib/python2.7/dist-", line 491, in call result = self.forward(input, kwargs) File "/home/faster-", line 50, in forward rois, rpnlosscls, rpnlossbbox = self.RCNNrpn(basefeat, iminfo, gtboxes, numboxes) File "/usr/local/lib/python2.7/dist-", line 491, in call result = self.forward(input, kwargs) File "/home/faster-", line 87, in forward rpndata = self.RPNanchortarget((, gtboxes, iminfo, numboxes)) File "/usr/local/lib/python2.7/dist-", line 491, in call result = self.forward(input, kwargs) File "/home/faster-", line 157, in forward positiveweights = 1.0 / numexamples File "/usr/local/lib/python2.7/dist-", line 320, in rdiv return self.reciprocal() other RuntimeError: reciprocal is not implemented for type Exception NameError: "global name 'FileNotFoundError' is not defined" in &lt;bound method of object at 0x7fb842e6e3d0ignored This error is coming while implementing pytorch faster-rcnn repository. Any solutions please??
can you use the issue template, we need more information to help you.
Using Pytorch 0.3.0 solves the problem.
are you using python 2? AFAIK FileNotFoundError only exists in python 3, so this should be fixed Also, this error is hiding the real bug in the code, which seems to be the following: Did you mean to take the reciprocal of a LongTensor?
does the shutdown workers FileNotFoundError happen on python 2.7 as well?
I haven't tested on py2. But I believe it should be an with errno.
Yup I am using Python 2. To overcome this error of FileNotFoundError I have downgraded Pytorch from 0.4.0 version to 0.3.0. Use Pytorch 0.3.0 with Python 2, it will work fine.
alternatively, upgrading to Python 3 will fix the issue (and Python 3 is nicer than Python 2).
Code change:
from collections import defaultdict import torch <del> try: FileNotFoundError except NameError: # py2.7 FileNotFoundError = IOError </del> <ins> from torch._six import FileNotFoundError </ins> class range(object):

Related discussion:
text: We'll fix this though.
For a quick fix you can make python2 compatible by defining FileNotFoundError somewhere
This error still exist in pytorch 0.4
Yes it is fixed after 0.4
I am still getting it...
did you build pytorch from source? It was fixed after 0.4 is released, so it will be in the next pytorch release.
I updated it via
Can anyone help me with my problem?
I was also working with faster r-cnn and got the error. Downgrading to 0.3.0 solved FileNotFoundError but will produce another error: self.ratiolistbatch[leftidx:(rightidx+1)] = ((np.float64)) # trainset ratio list ,each batch is same number TypeError: 'module' object is not callable Where this error is related to in the above error message. Upgrading can solve this error but will produce the previous one. How do you cope with the second error?
Code change:
self.assertEqual(output.names, ['N', 'H', 'W', 'C']) self.assertEqual(output.shape, [3, 5, 1, 2]) <ins> @unittest.skip("Not implemented yet") </ins> def test_align_tensors_two_inputs(self): def _test(tensor_namedshape, align_names, expected_sizes, expected_error): tensor_names, tensor_sizes = tensor_namedshape

Related discussion:
text: only supports fully named inputs; all input dimensions must have a name. When passing it an unnamed input, it errors out with the following message: It should really say "Found unnamed dim at index 0 of Tensor[None, None]".
fixed in
Code change:
self.assertEqual(output.names, ['N', 'H', 'W', 'C']) self.assertEqual(output.shape, [3, 5, 1, 2]) <ins> @unittest.skip("Not implemented yet") </ins> def test_align_tensors_two_inputs(self): def _test(tensor_namedshape, align_names, expected_sizes, expected_error): tensor_names, tensor_sizes = tensor_namedshape

Related discussion:
text: This is an older implementation that I think doesn't make any sense anymore. We should throw a NYI exception for it. The expected behavior for this should be:
fixed in
Code change:
#define THC_GENERIC_FILE "generic/THCTensorIndex.cu" #else <ins> // Check tensor dimensions for index operations, and return the slice size. // src can be nullptr in case of indexFill: in that case it is ignored. static ptrdiff_t THCTensor_(getSliceSize)(THCState *state, THCTensor *dst, int dim, THCudaLongTensor *index, THCTensor *src) { int dstDims = THCTensor_(nDimension)(state, dst); int srcDims = (src == nullptr) ? dstDims : THCTensor_(nDimension)(state, src); THArgCheck(THCudaLongTensor_nDimension(state, index) == 1, 4, "expecting vector of indices"); THArgCheck(dim >= 0 && dim < dstDims, 2, "Indexing dim is out of bounds"); ptrdiff_t dstSliceSize = 1; for (int d = 0; d < dstDims; d++) { if (d != dim) { dstSliceSize *= dst->size[d]; } } if (src == nullptr) return dstSliceSize; THArgCheck(dim < srcDims, 3, "Indexing dim is out of bounds"); THArgCheck(THCudaLongTensor_nElement(state, index) == src->size[dim], 4, "length of src.size[dim] is not equal to length of indices"); ptrdiff_t srcSliceSize = 1; bool mismatch = false; if (dstDims != srcDims) mismatch = true; for (int d = 0; d < srcDims; d++) { if (d != dim) { srcSliceSize *= src->size[d]; if (!mismatch && dst->size[d] != src->size[d]) mismatch = true; } } THArgCheck(dstSliceSize == srcSliceSize, 2, "Source/destination tensor have different slice sizes (%ld vs %ld)", dstSliceSize, srcSliceSize); if (mismatch) { static bool warningShown = false; if (!warningShown) { warningShown = true; fprintf(stderr, "Warning: source/destination slices have same size but different " "shape for an index operation.  This behavior is deprecated.n"); } } return dstSliceSize; } </ins> void THCTensor_(indexCopy_long)(THCState *state, THCTensor *dst, int dim, THLongTensor *indices, THCTensor *src) { THCAssertSameGPU(THCTensor_(checkGPU)(state, 2, dst, src));

Related discussion:
text: A = (5, 4) B = (0, 9).view(3, 3) C = (0, 15).view(3, 5) idxs = torch.LongTensor([0, 2, 4]) A.indexadd(0, idxs, B) # RuntimeError: inconsistent tensor size, expected r [4], t [4] and src [3] to have the same number of elements, but got 4, 4 and 3 elements respectively at (...)/aten/src/TH/generic/THTensorMath.c:1008 A.indexadd(0, idxs, C) # RuntimeError: inconsistent tensor size, expected r [4], t [4] and src [5] to have the same number of elements, but got 4, 4 and 5 elements respectively at (...)/aten/src/TH/generic/THTensorMath.c:1008 So far so good. But if we use CUDA... A = (5, 4).cuda() B = (0, 9).view(3, 3).cuda() C = (0, 15).view(3, 5).cuda() idxs = torch.LongTensor([0, 2, 4]).cuda() A.indexadd(0, idxs, B) print(A) # 0 1 2 0 # 0 0 0 0 # 3 4 5 0 # 0 0 0 0 # 6 7 8 0 # [ of size 5x4 (GPU 0)] OK, this looks wrong... A.zero() A.indexadd(0, idxs, C) print(A) # 0 1 2 3 # 4 0 0 0 # 5 6 7 8 # 9 0 0 0 # 10 11 12 13 # [ of size 5x4 (GPU 0)] Now this looks definitely wrong. Increase C's dimension to something like (3, 500), and it overwrites other tensors or triggers asserts. Same thing happens with indexcopy_.
I'll take it if no one's looking at it yet.
Code change:
.. math:: f(X) = sqrt[p]{sum_{x in X} x^{p}} <del> - At p = infinity, one gets Max Pooling - At p = 1, one gets Average Pooling </del> <ins> - At p = infinity, one gets Max Pooling - At p = 1, one gets Sum Pooling (which is proportional to Average Pooling) </ins> The parameters :attr:`kernel_size`, :attr:`stride` can either be:

Related discussion:
text: The math rendering doesn't end where it should, making the text after it difficult to read: <img width="719" alt="screen shot 2018-03-12 at 5 07 03 pm" src="https://user-"
Thanks for the report! Would you be interested in submitting a PR that fixes it?
Sure, I can give it a try!
This is being fixed in this PR
Code change:
} #if CUDA_VERSION >= 9010 <del> void THCudaBlas_HgemmStridedBatched(THCState *state, char transa, char transb, long m, long n, long k, half alpha, const half *a, long lda, long strideA, const half *b, long ldb, long strideB, half beta, half *c, long ldc, long strideC, long batchCount) </del> <ins> void THCudaBlas_HgemmStridedBatched(THCState *state, char transa, char transb, int64_t m, int64_t n, int64_t k, half alpha, const half *a, int64_t lda, int64_t strideA, const half *b, int64_t ldb, int64_t strideB, half beta, half *c, int64_t ldc, int64_t strideC, int64_t batchCount) </ins> { if( (m >= INT_MAX) || (n >= INT_MAX) || (k >= INT_MAX) || (lda >= INT_MAX)  || (ldb >= INT_MAX) || (ldc >= INT_MAX) || (batchCount >= INT_MAX) )

Related discussion:
text: I am trying to build PyTorch from source on macOS High Sierra Version 10.13.3 with an NVIDIA GeForce GT 750M. I'm following the instructions at prints prints prints prints When I enter , as per the instructions, I receive the following error message:
Carlos - this may be minor but I eventually found problems with ananconda for this an other CUDA-enabled builds. Couple of things that may help: a - ensure that your activated conda environment is env actually the env you want. I was checking the path with and it was showing the incorrect path to python and pip half of the time. I ended up creating new conda environments (switching to miniconda by the way) and passing the python=3.6 flag to ensure a full environment was deployed. Maybe somehow reverts back to an incorrect path b - in your activated environment, c - make sure a recent OS update didn't bump your CommandLineTools to v 9.0 (I found 8.0 was the only that worked, not 8.1) I built this on 10.12, CUDA 9, cudNN 7.0.
Could you see if can build for you? I don't have CUDA 9 on mac, so it'd be great if you can let me know if it works or not. :)
I'm no longer getting an error at installation, but still returns for some reason.
Code change:
END_HANDLE_TH_ERRORS } <ins> PyObject * THCPModule_getLibPath(PyObject *_unused) { #define _STR(x) #x #define STR(x) _STR(x) #if PY_MAJOR_VERSION == 2 return PyString_FromString(STR(CUDA_LIB_PATH)); #else return PyUnicode_FromString(STR(CUDA_LIB_PATH)); #endif #undef STR #undef _STR } </ins> //////////////////////////////////////////////////////////////////////////////// // Cuda module initialization ////////////////////////////////////////////////////////////////////////////////

Related discussion:
text: right now if is not in LDLIBRARYPATH, though it was found at compile-time, these lines will fail: Avoid this, by idk doing something... I think i have a few good ideas.
We need to add /usr/local/cuda/lib64 (or that's mac dir) to the rpath of _C
the problem i dont think is to add it to rpath, it's because we
Right. We could try with the default cuda installation path if it's not found from LDLIBRARYPATH.
Actually, do we really want to use the compile path? We should try to detect it at runtime, right? Or are we going to ship CUDA libs in our binaries?
we first load using runtime paths, and if it fails, fallback to path known at compile time.
I fear this is going to get brittle, especially if you are shipping CUDA libs. e.g. a user swaps HW and picks up a new driver and/or toolkit. As says, I'm pretty sure you want to use the runtime paths. Similarly, CUDA 7.5 won't run on Pascal and we have a cudnn built for 7.5 that will not do the right thing on CUDA 8, so those need to go together. If a user installs the CUDA bits via deb/rpm the right things are supposed to happen. If you push bits, we need to figure out how to make sure things line up. But this is perhaps a much larger packaging conversation.
Yeah, I've implemented it to first try loading it without any path and then try and . I'll push the commit tomorrow.
Code change:
def backward(self, grad_output): # TODO: not sure if this clone is necessary <del> return grad_output.clone().view(self.input_size) </del> <ins> return grad_output.contiguous().view(self.input_size) </ins> class Expand(Function):

Related discussion:
text: Libtorch LTS couldn't be downloaded! to ! the link For example: (Linux) (Windows) There's the error ! LibTorch LTS(1.8.2) could be downloaded One user has reported the issue in forum cc
cc:
I can take care of this today, seems with the new lts stuff we neglected the libtorch uploads
Code change:
static inline __host__ __device__  uint8_t mul(uint8_t a, uint8_t b) { return a * b; } static inline __host__ __device__  uint8_t sub(uint8_t a, uint8_t b) { return a - b; } static inline __host__ __device__  uint8_t div(uint8_t a, uint8_t b) { return a / b; } <del> static inline __host__ __device__  uint8_t abs(uint8_t a) { return abs(a); } </del> <ins> static inline __host__ __device__  uint8_t abs(uint8_t a) { return a; } </ins> }; template <>

Related discussion:
text: My compiler (Apple LLVM version 8.1.0 (clang-802.0.42) complained about this, but I think it's reasonable. In the specialization THCNumerics<uint8tthe abs-function is defined in a selfrecursive way ie uint8t abs(uint8t a) { return abs(a); } Because an uint8t has no sign it should imo defined as uint8t abs(uint8t a) { return a; }
Yup that's an error. Can you please send a PR?
I am sorry. I am inexperienced with that and have not currently time. But I will soon invest some time in learning it.
I'm volunteer to push a patch for this issue.
Code change:
import traceback import os import time <del> from torch._six import string_classes, int_classes </del> <ins> from torch._six import string_classes, int_classes, FileNotFoundError </ins> IS_WINDOWS = sys.platform == "win32" if IS_WINDOWS:

Related discussion:
text: Traceback (most recent call last): File "", line 322, in &lt;moduleroislabel = fasterRCNN(imdata, iminfo, gtboxes, numboxes) File "/usr/local/lib/python2.7/dist-", line 491, in call result = self.forward(input, kwargs) File "/home/faster-", line 50, in forward rois, rpnlosscls, rpnlossbbox = self.RCNNrpn(basefeat, iminfo, gtboxes, numboxes) File "/usr/local/lib/python2.7/dist-", line 491, in call result = self.forward(input, kwargs) File "/home/faster-", line 87, in forward rpndata = self.RPNanchortarget((, gtboxes, iminfo, numboxes)) File "/usr/local/lib/python2.7/dist-", line 491, in call result = self.forward(input, kwargs) File "/home/faster-", line 157, in forward positiveweights = 1.0 / numexamples File "/usr/local/lib/python2.7/dist-", line 320, in rdiv return self.reciprocal() other RuntimeError: reciprocal is not implemented for type Exception NameError: "global name 'FileNotFoundError' is not defined" in &lt;bound method of object at 0x7fb842e6e3d0ignored This error is coming while implementing pytorch faster-rcnn repository. Any solutions please??
can you use the issue template, we need more information to help you.
Using Pytorch 0.3.0 solves the problem.
are you using python 2? AFAIK FileNotFoundError only exists in python 3, so this should be fixed Also, this error is hiding the real bug in the code, which seems to be the following: Did you mean to take the reciprocal of a LongTensor?
does the shutdown workers FileNotFoundError happen on python 2.7 as well?
I haven't tested on py2. But I believe it should be an with errno.
Yup I am using Python 2. To overcome this error of FileNotFoundError I have downgraded Pytorch from 0.4.0 version to 0.3.0. Use Pytorch 0.3.0 with Python 2, it will work fine.
alternatively, upgrading to Python 3 will fix the issue (and Python 3 is nicer than Python 2).
Code change:
import traceback import os import time <del> from torch._six import string_classes, int_classes </del> <ins> from torch._six import string_classes, int_classes, FileNotFoundError </ins> IS_WINDOWS = sys.platform == "win32" if IS_WINDOWS:

Related discussion:
text: We'll fix this though.
For a quick fix you can make python2 compatible by defining FileNotFoundError somewhere
This error still exist in pytorch 0.4
Yes it is fixed after 0.4
I am still getting it...
did you build pytorch from source? It was fixed after 0.4 is released, so it will be in the next pytorch release.
I updated it via
Can anyone help me with my problem?
I was also working with faster r-cnn and got the error. Downgrading to 0.3.0 solved FileNotFoundError but will produce another error: self.ratiolistbatch[leftidx:(rightidx+1)] = ((np.float64)) # trainset ratio list ,each batch is same number TypeError: 'module' object is not callable Where this error is related to in the above error message. Upgrading can solve this error but will produce the previous one. How do you cope with the second error?
Code change:
#endif #if CUDA_VERSION >= 9010 <del> void THCudaBlas_HgemmStridedBatched(THCState *state, char transa, char transb, long m, long n, long k, half alpha, const half *a, long lda, long strideA, const half *b, long ldb, long strideB, half beta, half *c, long ldc, long strideC, long batchCount); </del> <ins> void THCudaBlas_HgemmStridedBatched(THCState *state, char transa, char transb, int64_t m, int64_t n, int64_t k, half alpha, const half *a, int64_t lda, int64_t strideA, const half *b, int64_t ldb, int64_t strideB, half beta, half *c, int64_t ldc, int64_t strideC, int64_t batchCount); </ins> #endif /* Inverse */

Related discussion:
text: I am trying to build PyTorch from source on macOS High Sierra Version 10.13.3 with an NVIDIA GeForce GT 750M. I'm following the instructions at prints prints prints prints When I enter , as per the instructions, I receive the following error message:
Carlos - this may be minor but I eventually found problems with ananconda for this an other CUDA-enabled builds. Couple of things that may help: a - ensure that your activated conda environment is env actually the env you want. I was checking the path with and it was showing the incorrect path to python and pip half of the time. I ended up creating new conda environments (switching to miniconda by the way) and passing the python=3.6 flag to ensure a full environment was deployed. Maybe somehow reverts back to an incorrect path b - in your activated environment, c - make sure a recent OS update didn't bump your CommandLineTools to v 9.0 (I found 8.0 was the only that worked, not 8.1) I built this on 10.12, CUDA 9, cudNN 7.0.
Could you see if can build for you? I don't have CUDA 9 on mac, so it'd be great if you can let me know if it works or not. :)
I'm no longer getting an error at installation, but still returns for some reason.
Code change:
// So we'll convert all Numpy tensors of 0 elements to empty Torch tensors. if (PyArray_SIZE(array) != 0) { auto ndim = PyArray_NDIM(array); <ins> size_t storage_size = 1; </ins> THLongStoragePtr sizes = THLongStorage_newWithSize(ndim); long *sizes_data = sizes->data; for (int i = 0; i < ndim; ++i) {

Related discussion:
text: I followed the guide The command was working just fine until a couple days ago, but now it returns I manually checked and there is no cu100/[...] What should I do? I have CUDA 10.0 I would like to use pytorch...
You could try as a temporary workground. cc
This is most likely related to this: I've re-uploaded the stable html to re-include the cu100 binaries, and submitted a PR to make sure this doesn't happen again
Code change:
// So we'll convert all Numpy tensors of 0 elements to empty Torch tensors. if (PyArray_SIZE(array) != 0) { auto ndim = PyArray_NDIM(array); <ins> size_t storage_size = 1; </ins> THLongStoragePtr sizes = THLongStorage_newWithSize(ndim); long *sizes_data = sizes->data; for (int i = 0; i < ndim; ++i) {

Related discussion:
text: Repro: Strides seem to be copied correctly, and the first row is also ok. All other rows are garbage.
Code change:
import os.path import torch.nn.modules.activation import torch.autograd <ins> import matplotlib matplotlib.use('Agg') </ins> import pylab

Related discussion:
text: CC who was asking me about doc generation yesterday. Full log And CC
You probably know why this is happening, but just in case: fixes this. (as per: ) Matplotlib is trying to open a display window on what I assume is a screen-less server.
Code change:
self.assertEqual(output.shape, [3, 5, 1, 2]) # All input dimensions must be named <del> with self.assertRaisesRegex(RuntimeError, "All input dims must be named"): </del> <ins> with self.assertRaisesRegex(RuntimeError, "All input dims must be named. Found unnamed dim at index 0"): </ins> create('None:2,C:3').align_to('N', 'C') # not enough names

Related discussion:
text: only supports fully named inputs; all input dimensions must have a name. When passing it an unnamed input, it errors out with the following message: It should really say "Found unnamed dim at index 0 of Tensor[None, None]".
fixed in
Code change:
self.assertEqual(output.shape, [3, 5, 1, 2]) # All input dimensions must be named <del> with self.assertRaisesRegex(RuntimeError, "All input dims must be named"): </del> <ins> with self.assertRaisesRegex(RuntimeError, "All input dims must be named. Found unnamed dim at index 0"): </ins> create('None:2,C:3').align_to('N', 'C') # not enough names

Related discussion:
text: This is an older implementation that I think doesn't make any sense anymore. We should throw a NYI exception for it. The expected behavior for this should be:
fixed in
Code change:
dims = THCudaLongTensor_nDimension(state, indices); THArgCheck(dims <= MAX_CUTORCH_DIMS, 4, CUTORCH_DIM_WARNING); <del> ptrdiff_t numIndices = THCudaLongTensor_nElement(state, indices); int srcDims = THCTensor_(nDimension)(state, src); cudaStream_t stream = THCState_getCurrentStream(state); THArgCheck(THCudaLongTensor_nDimension(state, indices) == 1, 3, "expecting vector of indices"); THArgCheck(dim < srcDims, 4, "Indexing dim is out of bounds"); THArgCheck(srcDims > 0, 2, "Source tensor is empty"); THArgCheck(numIndices == src->size[dim], 4, "length of src.size[dim] is not equal to length of indices"); int indContig = THCudaLongTensor_isContiguous(state, indices); </del> // The `src` is partitioned into two parts: // -the size of each slice we are indexing, which is the // total size of the tensor ignoring dimension `dim`; // -the number of indices we are choosing, which is the total size // of the tensor `indices`. <ins> ptrdiff_t sliceSize = THCTensor_(getSliceSize)(state, dst, dim, indices, src); </ins> ptrdiff_t srcTotalSize = THCTensor_(nElement)(state, src); int64_t dstCopyDimSize = THCTensor_(size)(state, dst, dim); <del> ptrdiff_t sliceSize = srcTotalSize / numIndices; </del> <ins> ptrdiff_t numIndices = THCudaLongTensor_nElement(state, indices); cudaStream_t stream = THCState_getCurrentStream(state); int indContig = THCudaLongTensor_isContiguous(state, indices); </ins> int mpc = THCState_getCurrentDeviceProperties(state)->multiProcessorCount;

Related discussion:
text: A = (5, 4) B = (0, 9).view(3, 3) C = (0, 15).view(3, 5) idxs = torch.LongTensor([0, 2, 4]) A.indexadd(0, idxs, B) # RuntimeError: inconsistent tensor size, expected r [4], t [4] and src [3] to have the same number of elements, but got 4, 4 and 3 elements respectively at (...)/aten/src/TH/generic/THTensorMath.c:1008 A.indexadd(0, idxs, C) # RuntimeError: inconsistent tensor size, expected r [4], t [4] and src [5] to have the same number of elements, but got 4, 4 and 5 elements respectively at (...)/aten/src/TH/generic/THTensorMath.c:1008 So far so good. But if we use CUDA... A = (5, 4).cuda() B = (0, 9).view(3, 3).cuda() C = (0, 15).view(3, 5).cuda() idxs = torch.LongTensor([0, 2, 4]).cuda() A.indexadd(0, idxs, B) print(A) # 0 1 2 0 # 0 0 0 0 # 3 4 5 0 # 0 0 0 0 # 6 7 8 0 # [ of size 5x4 (GPU 0)] OK, this looks wrong... A.zero() A.indexadd(0, idxs, C) print(A) # 0 1 2 3 # 4 0 0 0 # 5 6 7 8 # 9 0 0 0 # 10 11 12 13 # [ of size 5x4 (GPU 0)] Now this looks definitely wrong. Increase C's dimension to something like (3, 500), and it overwrites other tensors or triggers asserts. Same thing happens with indexcopy_.
I'll take it if no one's looking at it yet.