oneflow.cuda

ONEFLOW.CUDA

Copyright 2020 The OneFlow Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

oneflow.cuda.BoolTensor(*args, **kwargs)

Creates a Tensor with the dtype of bool and it has the same parameters as oneflow.Tensor().

oneflow.cuda.ByteTensor(*args, **kwargs)

Creates a Tensor with the dtype of uint8 and it has the same parameters as oneflow.Tensor().

oneflow.cuda.CharTensor(*args, **kwargs)

Creates a Tensor with the dtype of int8 and it has the same parameters as oneflow.Tensor().

oneflow.cuda.DoubleTensor(*args, **kwargs)

Creates a Tensor with the dtype of float64 and it has the same parameters as oneflow.Tensor().

oneflow.cuda.FloatTensor(*args, **kwargs)

Creates a Tensor with the dtype of float32 and it has the same parameters as oneflow.Tensor().

oneflow.cuda.HalfTensor(*args, **kwargs)

Creates a Tensor with the dtype of float16 and it has the same parameters as oneflow.Tensor().

oneflow.cuda.IntTensor(*args, **kwargs)

Creates a Tensor with the dtype of int32 and it has the same parameters as oneflow.Tensor().

oneflow.cuda.LongTensor(*args, **kwargs)

Creates a Tensor with the dtype of int64 and it has the same parameters as oneflow.Tensor().

oneflow.cuda.current_device()int

Returns local rank as device index.

oneflow.cuda.device_count()int

Returns the number of GPUs available.

oneflow.cuda.is_available()bool

Returns a bool indicating if CUDA is currently available.

oneflow.cuda.manual_seed(seed: int)None

The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.cuda.manual_seed.html.

Sets the seed for generating random numbers for the current GPU. It’s safe to call this function if CUDA is not available; in that case, it is silently ignored.

Parameters

seed (int) – The desired seed.

Warning

If you are working with a multi-GPU model, this function is insufficient to get determinism. To seed all GPUs, use manual_seed_all().

oneflow.cuda.manual_seed_all(seed)None

The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.cuda.manual_seed_all.html.

Sets the seed for generating random numbers on all GPUs. It’s safe to call this function if CUDA is not available; in that case, it is silently ignored.

Parameters

seed (int) – The desired seed.