user_q
stringlengths
3
20
question
stringlengths
20
31k
user_a
stringclasses
5 values
answer
stringlengths
18
302
shabamee
I’m running into an issue where WeightedRandomSampler is only sampling data from one class.I’ve tried switching it for shuffle=True, and that works just fine, but I need to use weighted sampling since my data is imbalanced.Here’s the relevant code:batch_size = 64 transform = torch.jit.script(nn.Sequential( RandAug...
ptrblck
WeightedRandomSampler expects a weight tensor assigning the weight values to each sample, not the class index. Have a look atthis postwhich gives you an example.
arneo
I am stuck in this a bit for quite some time.I have a ground truth label array for size 5.y=tensor([903, 815, 214, 282, 694])I have the output for scores array of shape : [5,1000]scores = tensor([[ 1.0406, 1.1808, 4.4227, ..., 4.6864, 8.0145, 5.2128], [ 6.9101, 4.6083, 6.9259, ..., 9.7415, ...
ptrblck
Assuming you would like to get: x[0, 903] x[1, 815] ... then this should work: x = torch.randn(5, 1000) idx = torch.tensor([903, 815, 214, 282, 694]) x[torch.arange(x.size(0)), idx]
weizhen_song
image945×839 90.2 KBwhen I use it, it aways say:UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at …\c10/core/TensorImpl.h:1156.)return torch.max_pool2d(inp...
ptrblck
You can ignore it and update PyTorch (and torchvision) to the latest release, as the warning was unhelpful and was removed.
Alymostafa
I want to make a projection to the tensor of shape[197, 1, 768]to[197,1,128]usingnn.Conv()
ptrblck
You could use a kernel size and stride of 6, as that’s the factor between the input and output temporal size: x = torch.randn(197, 1, 768) conv = nn.Conv1d(in_channels=1, out_channels=1, kernel_size=6, stride=6) out = conv(x) print(out.shape) > torch.Size([197, 1, 128])
seyeeet
I am a little confuse regarding applying temporal convolution on the 1D data and appreciate it if someone can help me understand if I am doing it right.I have temporal data (x) in shape ofB x C x T(batch,channels,times). If I defineconv=nn.conv1d(C,C,3), would it means that I am applying convolution temporally with ker...
ptrblck
Yes, your description is correct. The conv layer will use a kernel size of 3 and will apply the convolution on the T dimension creating 3 activations maps. B, C, T = 3, 4, 10 x = torch.randn(B, C, T) conv = nn.Conv1d(C, C, 3) out = conv(x) print(out.shape) > torch.Size([3, 4, 8])
gebrahimi
I have a situation where I have 6 stack of decoders on top of each other and after that there are 2 heads and each head is a decoder. Some samples in the batch should go through the first 6 layers and the first head and some samples should go through the first six heads and the second decoder head. given a a batch size...
ptrblck
Since the entire batch seems to use the first 6 layers, you could directly pass it to them and split the batch afterwards e.g. by indexing. Once you have the two chunks you could then pass them to the corresponding head and if needed concatenate them afterwards (in the same order).
mimpi
Hi all,please can anyone tell me how to solve this issue? I am trying to train a net with the semi supervised method ‘mean teacher’ and have a problem to update the weight of the teacher.image1515×235 33.6 KB
ptrblck
Based on the error message you are running into a shape mismatch while trying to update one of the parameters. Check the shape of the parameters and make sure add_ would get the expected shapes.
ibrahim_khan
class segmodel(nn.Module):definit(self, depth=3,num_classes=22):super().init()self.pt = MLPin()self.encod1 = encoder1()self.encod2 = encoder()self.encod3 = encoder()self.encod4 = encoder()self.decod1 = decoder()self.decod2 = decoder()self.decod3 = decoder()self.decod4 = decoder()self.conv1 = nn.Conv1d(1, 64, 1)self.bn1...
ptrblck
Please post a minimal, executable code snippet as your current one uses undefined modules. You can post code snippets by wrapping them into three backticks ```.
MonkeyRn
Hi,I got a problem when I tried a naive regression example on 4 points. Here is my code.import numpy as np import torch from torch import nn device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') model = nn.Sequential( nn.Linear(D, H), nn.Sigmoid(), nn.Linear(H, C) ) model.to(device) # Con...
ptrblck
In the second use case you are ignoring the warning: UserWarning: Using a target size (torch.Size([4])) that is different to the input size (torch.Size([4, 1])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. which explains that broadcasting …
Bagg
torchvision/transforms/functional.py", line 743, in to_grayscale raise TypeError('img should be PIL Image. Got {}'.format(type(img))) TypeError: img should be PIL Image. Got <class 'torch.Tensor'>Hello, I understand the error. However, this should not happen. Transformation toGrayScale accepts both PIL images and T...
ptrblck
I guess your local setup might be using an older torchvision release, so you might want to update it.
Maxwell_Redacted
I have a some code written in C++ which I am rewriting to have in python,I wanted to check whether the two are compatible:at::max_out(tensor1, tensor2, tensor3)andtorch.max(tensor1, tensor2, out = tensor3)I have found the documentation slightly lacking on the matter
ptrblck
Yes, max_out is defined as: Tensor& max_out(const Tensor& self, const Tensor& other, Tensor& result) { return at::maximum_out(result, self, other); } so the last input tensor should be the out tensor.
erwawa
The error message is as follows,>>> torch.cuda.is_available() /home/yanjie/anaconda3/envs/sarah/lib/python3.7/site-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment, e.g. changing env variable CUDA_VISIBLE_DEVICES after progra...
ptrblck
A simple reboot shouldn’t cause any issues. However, by default your system might try to update all packages in each reboot and I guess that Ubuntu might have tried to update your NVIDIA drivers or CUDA and left them in a broken state.
PatricYan
loss = torch.nn.CrossEntropyLoss()loss_values = loss(train_output, train_label)train_output[128, 10, 27] , train_label[128, 10]get error:Expected target size (128, 27), got torch.Size([128, 10])
ptrblck
This would work: output = ... # shape [batch_size, seq_len, nb_classes] output = output.permute(0, 2, 1).contiguous() # shape [batch_size, nb_classes, seq_len]
Asya
Is there more efficient way to load all.npyarrays toDataLoader?this doesn’t work when there are too many arrays:files = glob.glob('./*) all_inputs = torch.tensor([]) all_labels = torch.tensor([]) for i in range(len(files)): input = torch.tensor(np.load('imgs_' + str(i) + '.npy')) all_inputs = torch.cat([all_i...
ptrblck
You could write a custom Dataset and lazily load each numpy array in the __getitem__.This tutorialmight be a good starter.
Asya
How to find mean and log variance from the encoder latent space?I receivex = self.enc5(x) # torch.Size([75, 16, 101, 101])from encoderand i would like to getmuandlogvarfromxto pass it to:def reparameterize(self, mu, log_var): """ :param mu: mean from the encoder's latent space :param log_var: lo...
ptrblck
The output of reparameterize seems to be a 2D tensor in the shape [75, 500], while self.decoder expects a 4D input and is most likely using a (transposed) conv layer. If that’s the case, unsqueeze the spatial dimensions and it might work: x = F.relu(self.decoder1(z[:, :, None, None]))
Asya
How to fix this error:RuntimeError: Shape of input must match shape of indicesin max_unpool2dreturn torch._C._nn.max_unpool2d(input, indices, output_size)when I’m trying to do unpooling on different size layer
ptrblck
As the error states the shape of the input and indices tensor have to match, which doesn’t seem to be the case in your script. Check the shapes via print(input.shape) and print(indices.shape) and make sure they are equal.
Omama
I want to train linear classifier with RNN encoder and decodertrain_fn(model, dataloaders)model = LinearClassifier(encoder=encoder, enc_type=‘rnn’, H=H, C=C)but I’m getting error here while training:pbar = tqdm(enumerate(train_dataloader),total=len(train_dataloader))The error is:TypeError: ‘NoneType’ object cannot be i...
ptrblck
Check the creation of the Dataset, sampler, and DataLoader as it seems as if the DataLoader got a None input as the dataset or sampler.
discort
To reproduce:Expected behaviour:def func(obj_x, obj_ind): new_x = torch.zeros((20, 3, 7), device=obj_x.device, dtype=torch.float32) j = torch.zeros((1,), device=obj_x.device, dtype=torch.long) for i, idx in enumerate(obj_ind[1:], start=1): new_x[idx][j] = obj_x[i] return new_x obj_x = torch.ran...
ptrblck
I think you are hitting multiple issues. The first one seems to be the “double indexing” which doesn’t assign the values to the original tensor. Index new_x and the assignment should work: new_x[idx, j] = obj_x[i] However, even though new_x would contain values now, it seems that enumerate(..., …
d_marcos
Hello, I am met with the following error in my ConvNet implementation.The error comes up when the trying to execute the self.blocks line in the forward method of the ConvNet.After investigation I realized my tensor would actually turn to None type after going through self.input_net in ConvNet forward.Also if helpful, I...
ptrblck
That’s great debugging! The reason for this is that you’ve forgotten to return out in the forward method of PreActResnetBlock. Adding it should solve the issue.
I-Love-U
When I use the normalized grid corresponding to the original coordinate system, as expected, the output should be the same as the original input.However, the actual output results are slightly different. Perhaps it is a precision issue?h_coord, w_coord = torch.meshgrid(torch.arange(7), torch.arange(7)) h_coord = h_coor...
ptrblck
Yes, I believe the small absolute errors are created by the limited floating point precision. I.e. the grid will contain floating point values, which might not be exactly representable. Using mode="bilinear" would then most likely try to interpolate the source values. You could use mode="nearest" t…
msuliman
Hi everyone.I have a model that is built on the top of multiple nn.Modules and my model have two loss functions. The error of one of these two loss functions will have to backpropagate through the whole network while the second error should only update one of the modules that build the model.As an example, my modules a...
ptrblck
You could use the inputs argument in backward to specify the gradient calculation for these parameters: class Model(nn.Module): def __init__(self): super().__init__() self.first_part = nn.Linear(10, 10) self.second_part = nn.Linear(10, 10) def forward(self, input): …
jimmiemunyi
I have searched online and the forums and the only solution so far I have found is to use this external library:GitHub - szymonmaszke/torchdata: PyTorch dataset extended with map, cache etc. (tensorflow.data like)So before I use that I was wondering whether there is a solution native to PyTorch.Here is my dataset:class...
ptrblck
Instead of using random_split you could create two CustomDataset instances each one with the different transformation: train_dataset = CustomDataset(filenames, train_transform) val_dataset = CustomDataset(filenames, train_transform) and then use Subset on both with their corresponding indices: tr…
I_H_Yoo
Hi.I specify a second GPU for training my model viaDEVICE = torch.device("cuda:1" if torch.cuda.is_available() is True else "cpu")but the memory of the first GPU, which is cuda:0 is allocated. Can you please let me know what am I missing?image955×630 18 KB
ptrblck
You are most likely creating the CUDA context on the default device and/or accidentally allocating additional memory on it. Mask the device you would like to use via CUDA_VISIBLE_DEVICES=1 python script.py args and use cuda:0 in the script to select the masked device.
Fangyuan
When the communication graph between threads is connected, the program will get stucked.It seems like a deadlock.But I don’t know how to figure it out.I write a simple demo to reproduce it.import os import torch import torch.distributed as dist from torch.multiprocessing import Process def run(rank, size): tensor...
ptrblck
The docs point out that the send is applied synchronously, so the process would wait until the tensor is received. If you want to use the async API use isend and irecv and make sure the tensors are available before using them.
jiwidi
Hi!So Ive been playing with pytorch lately and I end up with a model that seems poorly optimized. The gpu usage is around 30% all the time during training and depending on batch_size the time required to run a epoch can be drastically reduced (if batch_size is high) or long (if batch_size is small).The full code sits i...
ptrblck
You could try to profile the data loading and check if it might be slowing down your code using theImageNet example. If the data loading time is not approaching zero, you might want to take a look atthis post, which discusses common issues and provides more information. If the data loading is no…
Omama
How I can feed two pytorch models with different data, then concatenate the output of the two models before prediction.
ptrblck
I assume you would like to pass batches from training_loader1 as x1 and batches from training_loader2 as x2 to the model. If so, you could either iterate both loaders via zip or load the batches manually via: iter_loader1 = iter(training_loader1) batch1 = next(iter_loader1) ...
gemsanyou
As I see from the examples inCUDA semantics — PyTorch master documentation, the real input has the exact same shape of the static input of the initial recording of the graph.Can we use torch tensor of different shape (i.e, different batch size) for the real input?Moreover, can we use an object instead of torch.Tensor ...
ptrblck
No, as described in the docs: Replaying a graph sacrifices the dynamic flexibility of typical eager execution in exchange for greatly reduced CPU overhead. A graph’s arguments and kernels are fixed, so a graph replay skips all layers of argument setup and kernel dispatch, including Python, C++, an…
qingye_meng
I am running a Transformers BertForTokenClassification model in a arrch64 architecture pc.In the inference stage, I found that the speed is very slow.The speed mainly consumes in the following code:outputs = self.model(input_ids, input_mask, segment_ids)Then I used the watch command to find that only 1 cpu was used in...
ptrblck
I don’t know how you’ve installed PyTorch, but would assume you’ve built it from source (or did you find pip wheels for aarch64?). If so, did you install NEON on your system and was PyTorch detecting it during the build? This should use vectorized operations and could yield a speedup. Also, OpenBLA…
WAN
Hello, I have a dataset of text and labels and I want to do multiclass classification. I have 5 classes. I follow this toturial:Text Classification Pytorch | Build Text Classification ModelBut I needed to change the loss function to be:CrossEntropyLossloss = criterion(predictions, batch.Rating)this error keeps showing:...
ptrblck
nn.CrossEntropyLoss expects a model output in the shape [batch_size, nb_classes] and a target in [batch_size] containing class indices in the range [0, nb_classes-1] for a multi-class classification. Based on the error message I guess your target has an additional dimension, which should be removed…
Olivier-CR
Hi,I have a PyTorch seg training running on a SageMaker-managed EC2, and training errors after 1000 minibatches with the training Dataloader breaking because “RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0”What could cause this? One bad record in the dataset? Is ...
ptrblck
The error is most likely caused by an image with 4 channels (additional alpha channel), while the rest seem to use 3 channels (RGB only). You could iterate your DataLoader once and make sure it’s able to create the batches. How would a “fault-tolerant” dataset work? I.e. you could use a try/except …
errezeta
Hi,I have a *.csv file with time-series data that I want to load in a custom dataset and then use dataloader to get batches of data for an LSTM model.I’m struggling to get the batches together with the sequence size.This is the code that I have so far. I’m not even sure if I suppose to do it this way:class CMAPSSDatase...
ptrblck
Based on the error message it seems you are dealing with variable sequence lengths. The collate_fn of the DataLoader tries to stack the samples into a single batch, which would fail if the dimensions (besides the batch dim) don’t have the same shape. You could e.g. pad the smaller sequences to the …
hideinshadow
When I was checking the feature maps of my model, I found something bizarre:Although each channel of the input tensor X (the size of x is 256 * 9 * 9, C * H * W) is a constant value. The result of X.mean(0) is not in accord with expectations. The following is the result of plt.imshow(X.mean(0).numpy()):What this visual...
ptrblck
Yes, there won’t be a precision loss while transforming between numpy as PyTorch, since from_numpy and tensor.numpy() would share the underlying data. The difference would come from potentially different implementations (and order of operations) in the mean op.
Hussein
HelloI am using Google Colab for training contrastive learning model. All the code is from this notebookcolab.research.google.comGoogle ColaboratoryWhen I use PyTorch 1.9.0+cu102 and Torchvision 0.10.0+cu102 I got this error (RuntimeError: expected scalar type Half but found Float ) BUT when I use PyTorch 1.7.1 and Tor...
ptrblck
Thanks for the notebook! I can reproduce the issue in Colab using the older 1.9.0 release, while 1.9.1 works fine (also locally). I’ve used !pip install torch==1.9.1+cu111 https://download.pytorch.org/whl/torch_stable.html in the first cell to update PyTorch.
glennres
Hi all, I have a simple problem.I have aNetworkthat just has a line of feed forwardNeurons. EachNeuronjust does y=mx+b on the input, and applies sigmoid. I have two versions of my network:Version#1uses the nn.Module, nn.MSELoss, optim.SGD - this fails to learn.Version#2is similar to#1, but everything is manually calcul...
ptrblck
One difference would be the loss scale, since you are using the mean reduction in the first approach and a sum in the latter. Also, the latter trains for 1000 epochs with the entire dataset (all 2000 samples), while the former approach trains a single epoch with a single sample per batch in each ite…
minesh_mathew
If I have a 2D tensor (matrix) of size say (5,6), how do I transform it into a (10,3) matrix where each column in the resultant matrix is formed by stacking two consecutive columns in the initial matrix, with a step size of 2. That is, first two columns in the initial matrix are stacked to form the first column in th...
ptrblck
To create windows you could use tensor.unfold, which is also known as the im2col method.
rodriguez
I have two trained neural networks (NNs) that I want to combine to create a new neural network (with the same structure) but whose weights are a combination of the previous two neural networks’ weights.The two NNs have an accuracy of ~97%, but when I combine them I obtain a value of around 47%. The problem is not that ...
ptrblck
If you execute the update logic a few times you would be converging the value towards params1 as seen here: params1 = {'a': torch.empty(1).uniform_(-100, 100).item()} dict_params = {'a': torch.empty(1).uniform_(-100, 100).item()} beta = 0.5 print('target {}\nother {}'.format(params1, dict_params))…
jh_shim
x = torch.rand(2, 3, 128, 128) F.adaptive_avg_pool2d(x, output_size=1).flatten(start_dim=1)x = torch.rand(2, 3, 128, 128) x.mean(dim=(2, 3))Is there any difference between two above?I think both are same and the second one is more simple and understandable.But I assume there is any reason why most people are using firs...
ptrblck
There is no difference in the posted code snippets and the former one will also use the latter approach internally for an output_size of 1. The former allows you to use other output sizes and is thus more flexible. Also, you could use it as an nn.Module without creating a custom module for the mean …
Alva-2020
Hello, I want to know how to check the source code of torch.ops.torchaudio.sox_effects_apply_effects_file. I don’t know where I can see those codes?
ptrblck
I think you can find the definitionhere.
Samuel_Bachorik
Hi, when I use numpy.flip() on my array and then i try to create from this array torch tensor withtorch.from_numpy(x)It saysValueError: At least one stride in the given numpy array is negative, and tensors with negative strides are not currently supported. (You can probably work around this by making a copy of your ar...
ptrblck
Not the values in the array/tensor are negative but the strides, which are used to access elements in the tensor via indexing. Negative strides are not supported in PyTorch, so you would have to create a copy first: x = torch.randn(10, 10) x[:, ::-1] # > ValueError: step must be greater than zero…
martinr
Hi! torch.unique hasreturn_inverseargument. When set toTrueit will return an index to re-construct the original tensor from the sorted one.sorted_and_unique, idx = torch.unique(orig_input, 0, return_inverse=True) # recontruct the original (same as orig_input) original = sorted_and_unique[idx]Would there be a way to get...
ptrblck
I think scatter_ should work: orig_input = torch.randint(10, 15, (10,)) sorted_and_unique, idx = torch.unique(orig_input, sorted=True, return_inverse=True, dim=0) # recontruct the original (same as orig_input) original = sorted_and_unique[idx] print((orig_input == original).all()) > tensor(True) …
soulslicer
I am using the libtorch C++ API. How can I programatically disable CUDNN for testing purposes?
ptrblck
I think this should work: at::globalContext().setUserEnabledCuDNN(false);
timgianitsos
PyTorch has new functionalitytorch.inference_modeas of v1.9 which is “analogous totorch.no_grad… Code run under this mode gets better performance by disabling view tracking and version counter bumps.”If I am just evaluating my model at test time (i.e. not training), is there any situation wheretorch.no_gradis preferabl...
ptrblck
Yes, you can depend on runtime errors and as long as no errors are raised, you code should be fine. One difference would be that you are not allowed to set the requires_grad attribute on tensors from an inference_mode context: with torch.no_grad(): x = torch.randn(1) y = x + 1 y.requires_…
maciejbalawejder
The output image of torchvision.transforms return a batch of same images turned grey, even though it suppose to turn it into tensor. I attach the image of the generated output(left) and the reference of the image taken from dataset(right). I was trying to look on the forums but I havent found anything also I tested it ...
ptrblck
Thanks! The transformation works as intended and this code properly visualizes the normalized image: img = PIL.Image.open('tmp02.jpeg') transform = torchvision.transforms.Compose([ torchvision.transforms.ToTensor() ]) out = transform(img) plt.imshow(out.permute(1, 2, 0).numpy()) [image] …
Younggun_Lee
In pytorch tutorial, I found thisarticle.It says, if you have dataset of variable lengths then pre-allocating memory with the maximum length of input can help avoiding OOM error.Pre-allocation of memory can be done by the following steps:generate a (usually random) batch of inputs with maximum sequence length (either c...
ptrblck
You should do it once before the actual training starts, as the memory would be pre-allocated and moved to the cache afterwards. As long as you don’t clear the cache via torch.cuda.empty_cache() you wouldn’t have to rerun it.
Snowbow
Hello, i’m new to Pytorch and nlp.I’m doing a Reinforcement Learning Project and I’m using GRU as the network. But when I changing the “num_layers” to 2, it comes a ValueError:“ValueError: too many values to unpack (expected 2)”Here is my code:class ActorNetwork(nn.Module): def __init__(self, input_size, alpha, hid...
ptrblck
As described in thedocsnn.GRU yields two outputs: output and h_n. You are unwrapping the second return value into h_n and h_c, which works fine if a single layer is used, since the shape of h_n is defined as [directions * num_layers, batch_size, H_out] (directions=2 since you are using bidirectio…
b-cute
Hi all,Sorry for the potential noob post, but I encountered today what is not strictly a problem, but rather an unexpected behavior.When using atorch.nn.functional.conv1d(), it is specified in the documentation that the input tensor shape should be of dimension[minibatch, in_channels, iW]. But it seems to be also worki...
ptrblck
I guess some checks might not be triggered for an unexpected shape as long as it’s not invalid and based onthis codeit seems that besides a different output_padding? argument the internal call would be equal. I would still recommend to use the corresponding function, as internals could be changed…
Olivier-CR
Hi,I’m trying to train a DeepLabV3 model on a segmentation dataset where annotations come as PNG pictures with 55 different colors.When I read such an annotation PNG with PyTorch image_read I get the following tensor (shape [3,H,W])tensor([[[135, 135, 135, ..., 135, 135, 135], [135, 135, 135, ..., 135, 135, ...
ptrblck
This postgives you an example of a color to class index mapping for the targets of a segmentation use case.
Keyboard_Crasher
Greetings, everyone!I’m having trouble with loading custom datasets into PyTorch Forecasting. I already posted the question toStack Overflowbut it seems that I might find the answer here here’s the message pasted for your convenience:I’m trying to load a custom dataset to PyTorch Forecasting by modifying the example gi...
ptrblck
What happens if you remove the filtering by using 0 for the min. values and a huge number for the max. ones?
Malik7115
Hello, I am interested in having the model inference in C++. The model is trained in python, I have a few questions regarding libtorch vs Custom C++ extensions of pytorch.the main difference between libtorch vs Custom C++ extensions of pytorch (can both be used for inference?)Which one is better in terms of both ease o...
ptrblck
libtorch is the C++ frontend while custom C++/CUDA extensions can be used in Python as modules or functional ops. Yes, both can be used for inference.@tom’s general rule is: “As long as your operands are reasonably large (say 100s of elements, not single elements), Python and Data “administrat…
jdenize
Hi,I would like to train a model on imagenet, but with the default ImageFolder, it is taking too long to train.To speed up the training process, I want to cache the dataset in RAM. I’ve seen that one way to cache the dataset is to create a large numpy tensor or a list of tensors such as what is done in small datasets (...
ptrblck
Yes, I think you are right regarding the shuffling in DistributedSampler. If you want to share arrays with a different shape you might want to check theshared_dictimplementation and see if this would be a valid approach.
James_Lee
Hello. I’m trying to set ignore_index for labels during training with CE loss, my code seemed as follows,for i, data in enumerate(train_loader): labels[labels > 0.9] = 1 labels[labels < 0.1] = 0 # bug occurred here labels[0.1<=labels<=0.9] = -1 loss = nn.CrossEntropyLoss(out, l...
ptrblck
You have to combine the two conditions via &: labels[(0.1<=labels) & (labels<=0.9)]
Adwaitt
Hello everyoneI am working on the segmentation problem and images are grayscale but I stacked them along the depth which made each channel to be a 4 channel image and I also did the one hot encoding for my mask there were 4 labels in total one of them was the background (I also want to know how to exclude that altogeth...
ptrblck
I don’t know what memory layout nib uses, but I would guess it’s channels-last (same as OpenCV)? If so, you are interleaving the images most likely via: images[135].reshape(1, 4, 256, 160) and should change it to a tensor.permute or numpy_array.transpose if you want to change the dimension order. …
MRRP
Hi Pytorch CommunityI asked once before but no one answered to my question so now i will ask it again and i will appreciate if you can provide me with any help.I have a dictionary which contains a few tensors(Fisher matrix of a CNN) like below:Fisher = {conv1.weight = 'a tensor of shape(6,3,5,5), conv1.bias = …,}now i ...
ptrblck
In that case masking should work: model = models.resnet18() sd = model.state_dict() for key in sd: print(key) print('abs.sum before {}'.format(sd[key].abs().sum())) mask = torch.empty_like(sd[key]) mask.random_(0, 2) print('mask, 0s: {}, nelement: {}'.format(mask.sum(), mask.ne…
jhp
Hi i;m stuck right now in OOM issue.| distributed init (rank 0): env:// | distribu...
ptrblck
You could try to reset your device via: sudo rmmod nvidia_uvm sudo modprobe nvidia_uvm as it seems to be in a “bad state” (e.g. after using hibernate/sleep in Linux).
MinkyuChoi
Seeing thetorch.angle()description (torch.angle — PyTorch 1.9.1 documentation), it says that the behavior oftorch.angle()has been changed since 1.8.0. Following is the note from the link.====== Note =======Starting in PyTorch 1.8, angle returns pi for negative real numbers, zero for non-negative real numbers, and propa...
ptrblck
“Propagates NaNs” means that this module will output NaN values if the input was already containing NaNs (so it propagates/forwards them). This should apply for the forward and backward methods. Based on the description I would guess that NaN inputs were mapped to zeros in previous versions.
YutongZheng
Hello, I am using a cpp_extension function written with .cpp and .cu built with torch.utils.cpp_extension._get_build_directory. It works FINE with one GPU. But with distributed parallel training, an error always occurs:terminate called after throwing an instance of 'std::runtime_error' what(): NCCL error in: ../torc...
ptrblck
I guess you are missing the deviceGuard via: const at::cuda::OptionalCUDAGuard device_guard(device_of(tensor)); which would use the default device in your custom CUDA extension and will thus run into illegal memory accesses.
Yujian_Liu
Given a 1D tensor x, and a 2D tensor (N * 2) of start and end indices, is there a way to set the values in the start and end range to a specific value (say 0)?I’m looking for a vectorized way to do the following:>>> x = torch.randint(10, (8,))>>> xtensor([1, 6, 1, 9, 3, 2, 6, 2])>>> indices = torch.tensor([[1,2], [4,6]...
ptrblck
You could create a mask using cumsum and set the values to zero as seen here: x = torch.tensor([1, 6, 1, 9, 3, 2, 6, 2]) indices = torch.tensor([[1,2], [4,6]]) val = torch.tensor([[1, -1], [1, -1]]) mask = torch.zeros_like(x).scatter_( 0, indices.view(-1), val.view(-1)).cumsum(0).bool() x[mas…
abhidipbhattacharyya
Does it matter if I create optimizer before or after uploading the model in GPU. For examplemodel = myModel() optimizer = torch.optim.Adamax(model.parameters()) model = model.to(device)vs.model = myModel() model = model.to(device) optimizer = torch.optim.Adamax(model.parameters())Thanks,Abhidip
ptrblck
It shouldn’t matter, as the optimizer should hold the references to the parameter (even after moving them). However, the “safer” approach would be to move the model to the device first and create the optimizer afterwards.
Bramahan
I used a Siamese network with contrastive loss as image below, but after few epochs, the loss gave nan value with messageerror :'RuntimeError: Function 'PowBackward0' returned nan values in its 0th output.I have searched this issue, but haven’t find solution yet. I think the problem would be my loss function. Can someo...
ptrblck
Try to isolate the iteration which causes this issue and check the inputs as well as outputs to torch.pow. Based on your code I cannot find anything obviously wrong. Also, I would recommend to post code snippets directly by wrapping them into three backticks ``` (as you’ve already done), as it would…
Karthik_CS
# License: BSD # Author: Sasank Chilamkurthy from __future__ import print_function, division import torch import torch.nn as nn import torch.optim as optim from torch.optim import lr_scheduler import numpy as np import torchvision from torchvision import datasets, models, transforms import matplotlib.pyplot as plt im...
ptrblck
Why would you expect to see the same training and validation loss? Assuming you are using model.train() and model.eval() properly, the batchnorm layers might not converged their running stats to the batch statistics and would thus output “not perfectly normalized” data during validation.
shashimalcse
i have a tensor which shape is [4,1,224,224]. This is a 4 grayscale image batch. I want to get certain range values of each image. For example, the image grayscale range is 0 to 255, I want to get 30 to 40 values from the image and other pixels should be zero. is there a good way to do it?
ptrblck
torch.where should work: x = torch.randint(0, 256, (4, 1, 224, 224)) print(x.min(), x.max()) > tensor(0) tensor(255) out = torch.where((30<=x) & (x<=40), x, 0) print(out.unique()) > tensor([ 0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40])
manhdung20112000
DescribeRecently, I found that I can not initialize a random int tensor withrandintwhilerequires_gradis set to True.To Reproducetorch.randint(1, (10, 10), requires_grad=True)RuntimeError: Only Tensors of floating point and complex dtype can require gradientsAdditional informationWindows 10torchversion 1.9.0pythonversio...
ptrblck
This is not a bug and expected behavior. As the error message explains, only floating point types (and complex types, which are also using floating point types internally) can require gradients.
kasidkhansbp
I used Pytorch transform to transform the data and Pytorch model to train them. But, I am geting the error message as “RuntimeError: Given groups=1, weight of size [244, 244, 3, 3], expected input[8, 1, 244, 244] to have 244 channels, but got 1 channels instead”.Any suggestion on how to fix weight shape to accept the i...
ptrblck
The first conv layer: nn.Conv2d(244, 244, kernel_size=3, stride=1, padding=1) expects the input to have 244 channels, since in_channels=224. If you are passing an input with a single channel, change in_channels to 1: nn.Conv2d(1, 244, kernel_size=3, stride=1, padding=1)
Asa-Nisi-Masa
I am getting an out of memory error for CUDA when running the following code:import torch assert torch.cuda.is_available() == 1 x = torch.randn(1) x.cuda() # RuntimeError: CUDA error: out of memoryRunning on GeForce GTX 750, Ubuntu 18.04. How can there not be enough memory for one float?
ptrblck
Could you check the current memory usage on the device via nvidia-smi and make sure that no other processes are running? Note that besides the tensor you would need to allocate the CUDA context on the device, which might take a few hundred MBs.
woojinchokimm
Hi all,I am relatively new to Pytorch so please bare me with meI have trained a network that takes as input 3 images. The net is based on this:1_-9XOKVUfl7D5pn29zK-lTw501×950 46.1 KBAfter training, I wish a heatmap for each input image for interpretability of results.I make a prediction based on a triplet of images, an...
ptrblck
argmax is not differentiable and will detach the resulting tensor from the computation graph, so you would have to remove it. I’m not familiar with your use case, but if you are working on e.g. a multi-class classification you should pass the raw logits to nn.CrossEntropyLoss instead.
legendu
I wonder does the GPU memory usage rough has a linear relationship with the batch size used in training?I was fine tune ResNet152. With a batch size 8, the total GPU memory used is around 4G and when the batch size is increased to 16 for training, the total GPU memory used is around 6G. The model itself takes about 2G....
ptrblck
The batch size would increase the activation sizes during the forward pass, while the model parameter (and gradients) would still use the same amount of memory as they are not depending on the used batch size.This postexplains the memory usage in more detail.
bluAsterisk
Hello,I have a question about how I can access the images from the call to ImageFolder() after feeding it into ConcatDataset(). This does seem to execute fine, but the ConcatDataset object doesn’t have an attribute for imgs that ImageFolder() has.Here is the code I am using to setup the training data, the commented lin...
ptrblck
My example code was accessing a random attribute to show that you would need to use the .datasets[index] approach to use it after wrapping the datasets into the ConcatDataset. In your current code snippet you are passing the shape of the underlying tensors to the method, which sounds wrong so just …
Asya
I am loading images as following:train_data = datasets.ImageFolder(data_dir, transform=transform['train']) lengths = [len(train_data) * 0.6, len(train_data) * 0.3, len(train_data) * 0.1] train_data, val_data, test_data = random_split(train_data, lengths) train_loader = torch.utils.data.DataLoader(train_data, shuffle=T...
ptrblck
The loss.backward operation isn’t sped up or slowed down by the usage of another Dataset, but depends on the model architecture as well as input shapes. If you’ve increased the input shapes in the new workflow, a slow down might be expected. Otherwise, I would guess you are timing your code wrong. …
JimW
I am trying to port some dataloader codes from codebase 1 to codebase 2.For codebase 2, the dataloader was based on ImageFolder, while the dataloader in codebase 1 was something where. What I did was to replace thegetitemof codebase2 with the one from codebase1, and it worked well.However, the other part of codebase...
ptrblck
Removing all internal self.samples should work, as the DatasetFolder class uses this attribute to get the length as seenhere. Alternatively, you could also try to monkey-patch the __len__(self) method and assign the desired value to it, assuming you want to reduce the number of samples and remove …
nbansal90
Hello,In my case I have a saved model namedbest_model.pkl, which inherently contains multiple models belonging topose,depthand other models. I was looking to use the existingbest_model.pklto extract the individual model and save them as separate.pthfiles.I am doing something on this line:model_to_save = torch.load('bes...
ptrblck
It seems that model_to_save['model_state'] contains a state_dict, which is the recommended way to serialize the models. To restore the model, create a model instance first and load the corresponding state_dict afterwards. I would not recommend to save the model directly via torch.save(model) but t…
bingqing_liu
import torch.nn as nn import torch class structural_attention_layer(nn.Module): def init(self): super(structural_attention_layer,self).init() def forward(self,a,b): return torch.randn(a,b) s_att=nn.Sequential() s_att.add_module(name="structural_attention_layer",module=structural_attention_...
ptrblck
Is this a double post fromherewith an already provided solution or what would be the difference in this code snippet?
mr_cell
Hi, I’m doing manual calculations for the LSTM layer and want to compare the results with the output of the program in PyTorch. However, I found the results were different. I use 1 layer of LSTM and initialized all of the bias and weight with values of 1 and the h_0 and c_0 value with 0.Here is the LSTM formula from th...
ptrblck
I haven’t checked your code, as you’ve posted images in the folder. However,this postmight be helpful, which shows a manual implementation to fix another user error.
alldbi
Hi,According to the expected behavior of batchnorm, its output should be the same in eval and training modes if the running stats are equal. However, I do not get consistent outputs when the stats are the same. For instance, please consider the following toy example in which the outputs of two exact batchnorm modules a...
ptrblck
No, that’s not true. During training, the input activation will be normalized using the batch statistics (so the stats calculated from the input activation itself) and the running stats will be updated using the momentum, the current batch stats, and the old running stats. During evaluation, the …
torchy
Hi Everyone,I am unable to find any documentation on how to set multiple GPUs for inference.In python the following can be done:device = torch.device(“cuda” if torch.cuda.is_available() else “cpu”)model = CreateModel()model= nn.DataParallel(model)model.to(device)However for C++ I can’t find the equivalent or any docume...
ptrblck
libtorch uses the parallel::data_parallel API as seen e.g.here. I don’t know if there are other wrappers, but based on the examples I would guess they should work in a similar way as the DataParallel wrapper in Python.
bingqing_liu
class structural_attention_layer(nn.Module):definit(self):super(structural_attention_layer,self).init()def forward(self,hello,world): return torch.randn(node_num,emb_size)s_att=nn.Sequential()s_att.add_module(name=“structural_attention_layer”,module=structural_attention_layer())s_att(1,2)error occurs like the t...
ptrblck
nn.Sequential container use a single input and output tensor as the input and output activation. You could write a custom nn.Module for multiple inputs or check e.g.this topicfor more information and potential workarounds.
braindotai
I want to change the gradients during a backward pass for each Conv2d modules, so I’m trying to figure out how to change the input_gradiens using the backward hook, but cannot figure out what to return from the hook function in order to change the input_gradients.def backward_hook(module, input_grads, output_grads): ...
ptrblck
I don’t think you should return the output_grads, as they were already passed to the module and won’t be used anymore. Instead you should return all input gradients, which would be passed to the “previous” layer (previous in the sense of the forward execution). Also use register_full_backward_hook, …
Asya
I receive an error:RuntimeError: size mismatch, m1: [3072 x 32], m2: [3072 x 32] at /opt/conda/conda-bld/pytorch_1587428091666/work/aten/src/THC/generic/THCTensorMathBlas.cu:283when I’m trying to add classifier to autoencoder:class ConvAutoencoder(nn.Module): def __init__(self): super(ConvAutoencoder, self)...
ptrblck
Based on the error message, the activation input has 32 features so you would need to use in_features=32 in the linear layer: lin = nn.Linear(32 * 32 * 3, 32) x = torch.randn(32 * 32 * 3, 32) out = lin(x) > RuntimeError: mat1 and mat2 shapes cannot be multiplied (3072x32 and 3072x32) # works lin …
machina
RESOLVED: resolved it the issue, disc() (fc1) took size [32, 784] and I had the input tensor (adv_ex) as [32,28,28]Receiving a runtime error and I’m not sure why this line is causing it.Here is the code block:for epoch in range(num_epochs): for batch_idx, (real, labels) in enumerate(loader): #get a fixed in...
ptrblck
Yes, use the instructions from thewebsite.
PhysicsIsFun
Greetings!In order to print the initial loss of my network (before training), I want to feed the entire data set into my network like this:loss_train = np.zeros(epochs+1) accu_train = np.zeros(epochs+1) # initial loss output = model(batches_train.dataset.data) # batches_train is dataloader targe...
ptrblck
Creating a new DataLoader would be cheap in case you are lazily loading the data, so you might want to create a different one with this setup.
ArshadIram
Hi Community,It is just an informative question that may be very basic to most of you. I was reading about channel ordering. Pytorch prefers the first channel order like this [B, C, H, W] and TensorFlow support channel last order [B, H, W, C]. So I am wondering to know does change the channel order affect performance?W...
ptrblck
PyTorch uses channels-first by default and allows you to transform the input as well as model parameters to channels-last as describedhere, which could be beneficial for mixed-precision training using TensorCores. You can visualize the images using any library capable of it (e.g. PIL or matplotib)…
DumnBird
I have found some perfect answers to my question,but I am really afraid of latent bugs such as the Autograd problem, so could you please kindly tell meif the line4 in the following codes is ok? Would the torch.from_numpy create a new node in graph and make the grad of ‘conv.weight’ change because I use torch.from_num...
ptrblck
Yes, your approach looks wrong as the new parameter assignment would not keep the gradients, so you should copy them manually back, if you want to apply the previously calculated gradients to a new parameter set (assuming that’s what the linked method really does). Don’t use the .data attribute…
DumnBird
I am prepared to get rid of Tensorflow and join the club of Pytorch,and I found that Numpy can directly mannipulate torch.tensor,which is not supported in tensorflow1.x.And I am wondering why Numpy can directly manipulate torch.tensor which are not exactly np.array type?
ptrblck
PyTorch tensors implement the __array__ method, which is used for the interop between numpy and PyTorch, if I’m not mistaken. That being said, I would be careful with applying numpy operations directly on tensors especially if they require gradients and you want to backpropagate through them.
Arthur_Zakirov
Hello everyone,I’m trying to implement a training method, which trains the model on dataset A first and then continues the training on dataset B. Both datasets should be shuffled independently of each other. There is a class called torch.data.utils.ConcatDataset which enables the combination of 2 datasets however as fa...
ptrblck
Probably not the cleanest approach, but you could create the indices for both datasets first, shuffle them, wrap both datasets into a ConcatDataset, and use a Subset with the shuffled indices afterwards. Something like this might work: # create datasets dataset1 = torch.utils.data.TensorDataset(to…
coincheung
Hi,I would like to do something like this:a = torch.randint(0, 5, (6,)) inds = torch.randint(0, 7, (5,)) for i, ind in enumerate(inds): a[a==ind] = iThe for loop method is likely to be slow, is there better method to do this please ?
ptrblck
Yes, in that case my approach would work and you can compare the results as: inds = torch.tensor([3,5,7,8]) input = torch.tensor([5,5,5,8,8,3,7,3,7]) a = input.clone() b = input.clone() for i, ind in enumerate(inds): a[a==ind] = i idx = (b.unsqueeze(0) == inds.unsqueeze(1)).nonzero() b[idx…
minimalism-k
pytorch1.7.1+cuda11.0If I want to run pytorch with CUDA, what is the minimum cuda environment? (C++/CUDA extension is not required). Should I install all CUDA libraries? (cuNPP, cuSPARSE, cuBLAS, NCCL etc.)And, Does the torch-1.7.1+cu110-cp36-cp36m-linux_x86_64.whl contains a cuDNN lib? Should I install an additional p...
ptrblck
You would only need to install an NVIDIA driver to run PyTorch if you install the pip wheels or conda binaries, as they ship with the CUDA runtime, cuDNN, NCCL, cublas, etc.
eduardo4jesus
Comparing the FFT execution time with the one of Conv2d, I noticed that FFT operation is way slower than expected.Doing some investigation, I noticed the Conv2d uses the FFT method, and somehow is able to launch several stream.While when I callednn.funcitonal.fft.fft2(inputs)myself, I was only able to launch one stream...
ptrblck
You can usetorch.cuda.Streamto create custom streams. Check the docs carefully (as well as the streams parthere) as I would consider it an advanced mechanism since you can easily create race conditions in your code.
DeepLearner17
Hi,What is wrong with nn.Parameter ?l get the following error :TypeError: cannot assign ‘torch.cuda.FloatTensor’ as parameter ‘weight’ (torch.nn.Parameter or None expected)when l do the following :self.weight = torch.nn.Parameter(torch.FloatTensor(7,32,32),requires_grad=True).cuda() def forward(self,x): x=t...
ptrblck
torch.empty will create a tensor with uninitialized memory, so it won’t really be “empty” in the sense that no memory is used. No, Variables are deprecated since PyTorch 0.4.
pcpLiu
Hi,Is it possible to assign weights & bias of linear op in C++?auto m = torch::nn::Linear( torch::nn::LinearOptions(in_feature_dim, out_feature_dim).bias(true)); // assign weights & bias m.get()->weight.copy_(weight_py_tensor);????Searched around, didn’t find a good solution.Thanks!!
ptrblck
I’m not sure, if you need the get() operation, but you might want to add the NoGrad guard: torch::NoGradGuard no_grad; linear->weight.copy_(tensor); should work.
clbr
Hey there!I’m currently experimenting around with using cuda and opengl (pycuda/glumpy) to draw tensors to the screen. I’ve found a gist that seems to have implemented exactly what i want to do. The problem is that the project is quite old and it uses a few deprecated apis.The gist:gist.github.comhttps://gist.github.co...
ptrblck
Yes, but I would recommend to specify the dimension via tensor.squeeze(0) to make sure no other dimensions are removed in case they have a size of 1. I don’t know which PyTorch version was originally used, but I thought t() did not work on >2D data. In any case, use tensor = tensor.permute(1, 2, 0) …
Hatem
I am trying to bind a custom function to python using setup tools and following thetutorialbut I get the following error message although i was able to build it using cmake and worked successfully.I would appreciate any help, thank you.Blockquoterunning installrunning bdist_eggrunning egg_infocreating custom_conv2d_cpp...
ptrblck
Your custom extension seems to have trouble here: /home/hatem/Projects/pytorch_cpp/custom_conv/cpp_bind/conv-extension/conv_cpp_bind.cpp: At global scope: /home/hatem/Projects/pytorch_cpp/custom_conv/cpp_bind/conv-extension/conv_cpp_bind.cpp:74:16: error: expected constructor, destructor, or type c…
Mohamed_Nabih
Hello, I have two tensors with the following shapes ‘’’ A.shape = [2, 1, 64000], and B.shape=[2, 288, 16]’’’Is it possible to concatenate the two tensors of the last dim? I tried ‘’’ torch.cat((A, B), dim=-1) ‘’’ but it complains because dim 0 which is (1 , and 288 ) are not equal
ptrblck
Sorry, your previous explanation would work in this case: a = torch.randn([2, 1, 16]) b = torch.randn([2, 1, 64000]) c = torch.cat((a, b), dim=-1) as I’ve mistakenly saw torch.cat((A, B), dim=1) in your initial post instead of dim=-1.
Niels_PyTorch
In PyTorch, one can define parameters in the forward method rather than in the init method (when their shape depends on the size of the inputs).Small example (as explained inthis thread):class MyModule(nn.Module): def __init__(self): # you need to register the parameter names earlier self.register_p...
ptrblck
I don’t think there is a clean approach besides performing a “warmup” iteration using your real inputs to create the parameters. Afterwards, you could push the parameters to the desired device and pass them also to the optimizer. There is a newly added meta device, but I don’t think this would help …
legendu
If I do so, will iterating of 2 DataLoaders (backed by the same dataset) intervent with each other?
ptrblck
The DataLoader itself will not mutate the Dataset, as it’s calling into the Dataset to get the data, create batches, shuffle etc. However, the Dataset.__getitem__ could mutate the data in case you are manipulating it inplace (this is usually not wanted and caused errors in the past). There is also…
PhysicsIsFun
Greetings.I started using the pre-trained models in Torchvision such as Resnet18. As a first test, I wanted to adjust the pretrained model to CIFAR10. I changed the dimensions of the last layer, and froze all other layers. I decrease my learning rate every 10 epochs and train for 50 epochs. Yet, my accuracies seem to b...
ptrblck
This could indicate that you have already transformed the tensor to a numpy array and it shouldn’t be a problem anymore. In case loss is a tensor, check its .grad_fn attribute. If it’s showing a valid function, it’s attached to a computation graph, otherwise it’s detached.
mth1996
Hey guys,trying thattorch.utils.data.ConcatDatasetfunction to concatenate two Datasets together for the training process.Goal:Keep the original Dataset with no transformationsCreate a second dataset with transformationsDoing:Create a transformation withtransform = A.Compose([...])Create a Dataset classclass YOLODataset...
ptrblck
.numel() is defined for PyTorch tensors, not numpy arrays. Based on your error message it seems that you are using numpy arrays inside your Dataset, which then fails in: numel = sum([x.numel() for x in batch]) Assuming the __getitem__ returns these numpy arrays (I don’t have a clue which types the…
Najeh_Nafti
How can I create patches of size (64,64) for images with 3 channels and save them from a dataset of size (256,256).
ptrblck
No, it’s not randomly and the example in the docs would show how the kernel size and stride is applied. To reconstruct the input, you could take a look at thenn.Unfoldandnn.Folddocs.
Kaga
I know that in classification problems CrossEntropyLoss can be used. However, CrossEntroyLoss expects class index as input, not a one-hot encoded vector. While one-hot encoded vectors and class indices can be mapped to each other one-to-one, in my case I have vector outputs (in training data) that do not necessarily as...
ptrblck
@KFrankshared an implementation for “soft-labels”here.
soulslicer
I have a kernel of size [3,3] and an image of size [B, 3, H, W]I want to apply the same kernel in parallel across those 3 channels. They do not share data across channelsThis is my codeauto module = torch::nn::Conv2d( torch::nn::Conv2dOptions(3, 3, {3, 3}).padding(1).bias(false)); module->weight = kernel.unsqueez...
ptrblck
Your Python code is wrong, as you are creating a new .weights attribute while you would like to replace the .weight parameter. Change it to: x_kernel = torch.randn(3, 3) rgb_image = torch.randn(1, 3, 24, 24) conv = torch.nn.Conv2d(in_channels=3, out_channels=3, groups=1, kernel_size= (3,3), paddi…
Asya
I want to create tensor of shape=(None, 32, 32, 3)how can I do so?
ptrblck
You don’t need to use placeholder variables in PyTorch and can directly pass tensors to the model without specifying their shapes beforehand (similar to what you would be using in numpy).
ndronen
I’d like to upgrade NCCL on my system to2.10.3; it supports bfloat16, which I’d like to use. I don’t know the dependency relationships among Pytorch, CUDA, and NCCL. Does Pytorch have bindings to particular versions of NCCL, as suggested bythis issue? Can I choose to use a newer version of NCCL without upgrading either...
ptrblck
The PyTorch binaries ship with a statically linked NCCL using theNCCL submodule. The current CUDA11.3 nightly binary uses NCCL 2.10.3 already, so you could use it. On the other hand, if you want to use a specific NCCL version, which isn’t shipped in a binary release, you could build from source an…