"examples/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "b085224fb978c720c3f932c087e7b91a39fd34c3"
Unverified Commit fed540f2 authored by Hang Zhang's avatar Hang Zhang Committed by GitHub
Browse files

fix docker (#310)

* fix docker

* broken api
parent 1235f3b0
FROM nvcr.io/nvidia/pytorch:19.05-py3 FROM nvcr.io/nvidia/pytorch:20.06-py3
# Set working directory # Set working directory # Set working directory # Set working directory
WORKDIR /workspace WORKDIR /workspace
...@@ -8,14 +8,16 @@ WORKDIR /workspace ...@@ -8,14 +8,16 @@ WORKDIR /workspace
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y python3-tk python-pip git tmux htop tree RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y python3-tk python-pip git tmux htop tree
RUN python -m pip install --upgrade pip RUN python -m pip install --upgrade pip
RUN python -m pip install torch==1.4.0 #RUN python -m pip install torch==1.4.0
RUN python -m pip install torchvision==0.5.0 #RUN python -m pip install torchvision==0.5.0
RUN python -m pip install pycocotools==2.0.0 RUN python -m pip install pycocotools==2.0.0
#RUN chmod a+rwx -R /opt/conda/ #RUN chmod a+rwx -R /opt/conda/
COPY ./setup.py . COPY ./setup.py .
COPY ./encoding ./encoding COPY ./encoding ./encoding
ENV FORCE_CUDA="1"
RUN python setup.py develop RUN python setup.py develop
COPY ./experiments ./experiments COPY ./experiments ./experiments
...@@ -413,7 +413,7 @@ at::Tensor ROIAlign_Forward_CPU( ...@@ -413,7 +413,7 @@ at::Tensor ROIAlign_Forward_CPU(
AT_DISPATCH_FLOATING_TYPES(input.scalar_type(), "ROIAlign_Forward_CPU", ([&] { AT_DISPATCH_FLOATING_TYPES(input.scalar_type(), "ROIAlign_Forward_CPU", ([&] {
ROIAlignForwardCompute<scalar_t>( ROIAlignForwardCompute<scalar_t>(
output.numel(), output.numel(),
input.data<scalar_t>(), input.data_ptr<scalar_t>(),
static_cast<scalar_t>(spatial_scale), static_cast<scalar_t>(spatial_scale),
channels, channels,
height, height,
...@@ -421,9 +421,9 @@ at::Tensor ROIAlign_Forward_CPU( ...@@ -421,9 +421,9 @@ at::Tensor ROIAlign_Forward_CPU(
pooled_height, pooled_height,
pooled_width, pooled_width,
sampling_ratio, sampling_ratio,
bottom_rois.data<scalar_t>(), bottom_rois.data_ptr<scalar_t>(),
roi_cols, roi_cols,
output.data<scalar_t>()); output.data_ptr<scalar_t>());
})); }));
return output; return output;
...@@ -456,10 +456,10 @@ at::Tensor ROIAlign_Backward_CPU( ...@@ -456,10 +456,10 @@ at::Tensor ROIAlign_Backward_CPU(
AT_ASSERT(bottom_rois.is_contiguous()); AT_ASSERT(bottom_rois.is_contiguous());
AT_DISPATCH_FLOATING_TYPES(bottom_rois.type(), "ROIAlign_Backward_CPU", ([&] { AT_DISPATCH_FLOATING_TYPES(bottom_rois.scalar_type(), "ROIAlign_Backward_CPU", ([&] {
ROIAlignBackwardCompute<scalar_t>( ROIAlignBackwardCompute<scalar_t>(
grad_output.numel(), grad_output.numel(),
grad_output.data<scalar_t>(), grad_output.data_ptr<scalar_t>(),
num_rois, num_rois,
static_cast<scalar_t>(spatial_scale), static_cast<scalar_t>(spatial_scale),
channels, channels,
...@@ -468,8 +468,8 @@ at::Tensor ROIAlign_Backward_CPU( ...@@ -468,8 +468,8 @@ at::Tensor ROIAlign_Backward_CPU(
pooled_height, pooled_height,
pooled_width, pooled_width,
sampling_ratio, sampling_ratio,
grad_in.data<scalar_t>(), grad_in.data_ptr<scalar_t>(),
bottom_rois.data<scalar_t>(), bottom_rois.data_ptr<scalar_t>(),
roi_cols); roi_cols);
})); }));
......
#include <exception>
#include <torch/extension.h> #include <torch/extension.h>
#include <ATen/ATen.h> #include <ATen/ATen.h>
#include <vector> #include <vector>
...@@ -7,6 +8,7 @@ ...@@ -7,6 +8,7 @@
#include <thrust/transform.h> #include <thrust/transform.h>
#include "common.h" #include "common.h"
using namespace std;
namespace { namespace {
...@@ -40,5 +42,7 @@ void LeakyRelu_Backward_CUDA(at::Tensor z, at::Tensor dz, float slope) { ...@@ -40,5 +42,7 @@ void LeakyRelu_Backward_CUDA(at::Tensor z, at::Tensor dz, float slope) {
*/ */
// unstable after scaling // unstable after scaling
at::leaky_relu_(z, 1.0 / slope); at::leaky_relu_(z, 1.0 / slope);
at::leaky_relu_backward(dz, z, slope); // This API is changed on pytorch side, feature broken
throw "PyTorch API break, Don't use InplaceABN for now.";
// at::leaky_relu_backward(dz, z, slope, false);
} }
...@@ -101,7 +101,7 @@ struct DeviceTensor<DType, 1> { ...@@ -101,7 +101,7 @@ struct DeviceTensor<DType, 1> {
template<typename DType, int Dim> template<typename DType, int Dim>
static DeviceTensor<DType, Dim> devicetensor(const at::Tensor &blob) { static DeviceTensor<DType, Dim> devicetensor(const at::Tensor &blob) {
DType *data = blob.data<DType>(); DType *data = blob.data_ptr<DType>();
DeviceTensor<DType, Dim> tensor(data, nullptr); DeviceTensor<DType, Dim> tensor(data, nullptr);
for (int i = 0; i < Dim; ++i) { for (int i = 0; i < Dim; ++i) {
tensor.size_[i] = blob.size(i); tensor.size_[i] = blob.size(i);
......
...@@ -348,10 +348,10 @@ std::vector<at::Tensor> box_encoder(const int N_img, ...@@ -348,10 +348,10 @@ std::vector<at::Tensor> box_encoder(const int N_img,
const at::Tensor& dbox, const at::Tensor& dbox,
float criteria) { float criteria) {
// Check everything is on the device // Check everything is on the device
AT_ASSERTM(bbox_input.type().is_cuda(), "bboxes must be a CUDA tensor"); AT_ASSERTM(bbox_input.is_cuda(), "bboxes must be a CUDA tensor");
AT_ASSERTM(bbox_offsets.type().is_cuda(), "bbox offsets must be a CUDA tensor"); AT_ASSERTM(bbox_offsets.is_cuda(), "bbox offsets must be a CUDA tensor");
AT_ASSERTM(labels_input.type().is_cuda(), "labels must be a CUDA tensor"); AT_ASSERTM(labels_input.is_cuda(), "labels must be a CUDA tensor");
AT_ASSERTM(dbox.type().is_cuda(), "dboxes must be a CUDA tensor"); AT_ASSERTM(dbox.is_cuda(), "dboxes must be a CUDA tensor");
// Check at least offsets, bboxes and labels are consistent // Check at least offsets, bboxes and labels are consistent
// Note: offsets is N+1 vs. N for labels // Note: offsets is N+1 vs. N for labels
...@@ -374,7 +374,7 @@ std::vector<at::Tensor> box_encoder(const int N_img, ...@@ -374,7 +374,7 @@ std::vector<at::Tensor> box_encoder(const int N_img,
// allocate final outputs (known size) // allocate final outputs (known size)
#ifdef DEBUG #ifdef DEBUG
printf("%d x %d\n", N_img * M, 4); printf("%d x %d\n", N_img * M, 4);
// at::Tensor bbox_out = dbox.type().tensor({N_img * M, 4}); // at::Tensor bbox_out = dbox.scalar_type().tensor({N_img * M, 4});
printf("allocating %lu bytes for output labels\n", N_img*M*sizeof(long)); printf("allocating %lu bytes for output labels\n", N_img*M*sizeof(long));
#endif #endif
at::Tensor labels_out = at::empty({N_img * M}, labels_input.options()); at::Tensor labels_out = at::empty({N_img * M}, labels_input.options());
...@@ -398,15 +398,15 @@ std::vector<at::Tensor> box_encoder(const int N_img, ...@@ -398,15 +398,15 @@ std::vector<at::Tensor> box_encoder(const int N_img,
// Encode the inputs // Encode the inputs
const int THREADS_PER_BLOCK = 256; const int THREADS_PER_BLOCK = 256;
encode<THREADS_PER_BLOCK, 256><<<N_img, THREADS_PER_BLOCK, 0, stream.stream()>>>(N_img, encode<THREADS_PER_BLOCK, 256><<<N_img, THREADS_PER_BLOCK, 0, stream.stream()>>>(N_img,
(float4*)bbox_input.data<float>(), (float4*)bbox_input.data_ptr<float>(),
labels_input.data<long>(), labels_input.data_ptr<long>(),
bbox_offsets.data<int>(), bbox_offsets.data_ptr<int>(),
M, M,
(float4*)dbox.data<float>(), (float4*)dbox.data_ptr<float>(),
criteria, criteria,
workspace.data<uint8_t>(), workspace.data_ptr<uint8_t>(),
(float4*)bbox_out.data<float>(), (float4*)bbox_out.data_ptr<float>(),
labels_out.data<long>()); labels_out.data_ptr<long>());
THCudaCheck(cudaGetLastError()); THCudaCheck(cudaGetLastError());
return {bbox_out, labels_out}; return {bbox_out, labels_out};
...@@ -429,11 +429,11 @@ at::Tensor calc_ious(const int N_img, ...@@ -429,11 +429,11 @@ at::Tensor calc_ious(const int N_img,
// Get IoU of all source x default box pairs // Get IoU of all source x default box pairs
calc_ious_kernel<<<N_img, 256, 0, stream.stream()>>>( calc_ious_kernel<<<N_img, 256, 0, stream.stream()>>>(
N_img, N_img,
(float4*)boxes1.data<float>(), (float4*)boxes1.data_ptr<float>(),
boxes1_offsets.data<int>(), boxes1_offsets.data_ptr<int>(),
M, M,
(float4*)boxes2.data<float>(), (float4*)boxes2.data_ptr<float>(),
ious.data<float>()); ious.data_ptr<float>());
THCudaCheck(cudaGetLastError()); THCudaCheck(cudaGetLastError());
return ious; return ious;
...@@ -543,9 +543,9 @@ std::vector<at::Tensor> random_horiz_flip( ...@@ -543,9 +543,9 @@ std::vector<at::Tensor> random_horiz_flip(
W = img.size(3); W = img.size(3);
} }
assert(img.type().is_cuda()); assert(img.is_cuda());
assert(bboxes.type().is_cuda()); assert(bboxes.is_cuda());
assert(bbox_offsets.type().is_cuda()); assert(bbox_offsets.is_cuda());
// printf("%d %d %d %d\n", N, C, H, W); // printf("%d %d %d %d\n", N, C, H, W);
// Need temp storage of size img // Need temp storage of size img
...@@ -554,7 +554,7 @@ std::vector<at::Tensor> random_horiz_flip( ...@@ -554,7 +554,7 @@ std::vector<at::Tensor> random_horiz_flip(
auto stream = at::cuda::getCurrentCUDAStream(); auto stream = at::cuda::getCurrentCUDAStream();
AT_DISPATCH_FLOATING_TYPES_AND_HALF( AT_DISPATCH_FLOATING_TYPES_AND_HALF(
img.type(), img.scalar_type(),
"HorizFlipImagesAndBoxes", "HorizFlipImagesAndBoxes",
[&] { [&] {
HorizFlipImagesAndBoxes<scalar_t><<<N, dim3(16, 16), 0, stream.stream()>>>( HorizFlipImagesAndBoxes<scalar_t><<<N, dim3(16, 16), 0, stream.stream()>>>(
...@@ -562,12 +562,12 @@ std::vector<at::Tensor> random_horiz_flip( ...@@ -562,12 +562,12 @@ std::vector<at::Tensor> random_horiz_flip(
C, C,
H, H,
W, W,
img.data<scalar_t>(), img.data_ptr<scalar_t>(),
bboxes.data<float>(), bboxes.data_ptr<float>(),
bbox_offsets.data<int>(), bbox_offsets.data_ptr<int>(),
p, p,
flip.data<float>(), flip.data_ptr<float>(),
tmp_img.data<scalar_t>(), tmp_img.data_ptr<scalar_t>(),
nhwc); nhwc);
THCudaCheck(cudaGetLastError()); THCudaCheck(cudaGetLastError());
}); });
......
...@@ -71,8 +71,8 @@ std::vector<at::Tensor> Non_Max_Suppression_CUDA( ...@@ -71,8 +71,8 @@ std::vector<at::Tensor> Non_Max_Suppression_CUDA(
AT_ASSERT(input.size(2) == 4); AT_ASSERT(input.size(2) == 4);
AT_ASSERT(input.is_contiguous()); AT_ASSERT(input.is_contiguous());
AT_ASSERT(scores.is_contiguous()); AT_ASSERT(scores.is_contiguous());
AT_ASSERT(input.type().scalarType() == at::kFloat || input.type().scalarType() == at::kDouble); AT_ASSERT(input.scalar_type() == at::kFloat || input.scalar_type() == at::kDouble);
AT_ASSERT(scores.type().scalarType() == at::kFloat || scores.type().scalarType() == at::kDouble); AT_ASSERT(scores.scalar_type() == at::kFloat || scores.scalar_type() == at::kDouble);
auto num_boxes = input.size(1); auto num_boxes = input.size(1);
auto batch_size = input.size(0); auto batch_size = input.size(0);
...@@ -89,12 +89,12 @@ std::vector<at::Tensor> Non_Max_Suppression_CUDA( ...@@ -89,12 +89,12 @@ std::vector<at::Tensor> Non_Max_Suppression_CUDA(
//cudaGetDeviceProperties in the funcion body... //cudaGetDeviceProperties in the funcion body...
dim3 mask_grid(batch_size); dim3 mask_grid(batch_size);
if(input.type().scalarType() == at::kFloat) if(input.scalar_type() == at::kFloat)
{ {
nms_kernel<<<mask_grid, mask_block, 0, at::cuda::getCurrentCUDAStream()>>>( nms_kernel<<<mask_grid, mask_block, 0, at::cuda::getCurrentCUDAStream()>>>(
mask.data<unsigned char>(), mask.data_ptr<unsigned char>(),
input.data<float>(), input.data_ptr<float>(),
sorted_inds.data<int64_t>(), sorted_inds.data_ptr<int64_t>(),
num_boxes, num_boxes,
thresh); thresh);
AT_ASSERT(cudaGetLastError() == cudaSuccess); AT_ASSERT(cudaGetLastError() == cudaSuccess);
...@@ -102,9 +102,9 @@ std::vector<at::Tensor> Non_Max_Suppression_CUDA( ...@@ -102,9 +102,9 @@ std::vector<at::Tensor> Non_Max_Suppression_CUDA(
else else
{ {
nms_kernel<<<mask_grid, mask_block, 0, at::cuda::getCurrentCUDAStream()>>>( nms_kernel<<<mask_grid, mask_block, 0, at::cuda::getCurrentCUDAStream()>>>(
mask.data<unsigned char>(), mask.data_ptr<unsigned char>(),
input.data<double>(), input.data_ptr<double>(),
sorted_inds.data<int64_t>(), sorted_inds.data_ptr<int64_t>(),
num_boxes, num_boxes,
thresh); thresh);
AT_ASSERT(cudaGetLastError() == cudaSuccess); AT_ASSERT(cudaGetLastError() == cudaSuccess);
......
...@@ -379,7 +379,7 @@ at::Tensor ROIAlign_Forward_CUDA( ...@@ -379,7 +379,7 @@ at::Tensor ROIAlign_Forward_CUDA(
0, 0,
at::cuda::getCurrentCUDAStream()>>>( at::cuda::getCurrentCUDAStream()>>>(
count, count,
input.data<scalar_t>(), input.data_ptr<scalar_t>(),
static_cast<scalar_t>(spatial_scale), static_cast<scalar_t>(spatial_scale),
channels, channels,
height, height,
...@@ -387,8 +387,8 @@ at::Tensor ROIAlign_Forward_CUDA( ...@@ -387,8 +387,8 @@ at::Tensor ROIAlign_Forward_CUDA(
pooled_height, pooled_height,
pooled_width, pooled_width,
sampling_ratio, sampling_ratio,
rois.data<scalar_t>(), rois.data_ptr<scalar_t>(),
output.data<scalar_t>()); output.data_ptr<scalar_t>());
})); }));
AT_ASSERT(cudaGetLastError() == cudaSuccess); AT_ASSERT(cudaGetLastError() == cudaSuccess);
return output; return output;
...@@ -426,7 +426,7 @@ at::Tensor ROIAlign_Backward_CUDA( ...@@ -426,7 +426,7 @@ at::Tensor ROIAlign_Backward_CUDA(
0, 0,
at::cuda::getCurrentCUDAStream()>>>( at::cuda::getCurrentCUDAStream()>>>(
count, count,
grad_output.data<scalar_t>(), grad_output.data_ptr<scalar_t>(),
num_rois, num_rois,
static_cast<scalar_t>(spatial_scale), static_cast<scalar_t>(spatial_scale),
channels, channels,
...@@ -435,8 +435,8 @@ at::Tensor ROIAlign_Backward_CUDA( ...@@ -435,8 +435,8 @@ at::Tensor ROIAlign_Backward_CUDA(
pooled_height, pooled_height,
pooled_width, pooled_width,
sampling_ratio, sampling_ratio,
grad_in.data<scalar_t>(), grad_in.data_ptr<scalar_t>(),
rois.data<scalar_t>()); rois.data_ptr<scalar_t>());
})); }));
AT_ASSERT(cudaGetLastError() == cudaSuccess); AT_ASSERT(cudaGetLastError() == cudaSuccess);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment