Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions python/paddle/distributed/spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,6 @@ def __init__(self):
self.selected_devices = None


def _py_supported_check():
if not sys.version_info >= (3, 4):
raise RuntimeError(
"Use `paddle.distributed.spawn` to start parallel training "
"requires python version greater than 3.4, if your python "
"is lower than this version, please use "
"`paddle.distributed.launch` instead."
)


def _options_valid_check(options):
# `print_config` keeped as a debug options, not show to users
supported_options = [
Expand Down Expand Up @@ -414,7 +404,6 @@ def _func_wrapper(func, args, error_queue, return_queue, env_dict, backend):

class MultiprocessContext:
def __init__(self, processes, error_queues, return_queues):
_py_supported_check()
self.error_queues = error_queues
# NOTE(chenweihang): The `spawn` method is mainly used
# to wrap the outermost execution function of the program for
Expand Down Expand Up @@ -598,13 +587,6 @@ def train(print_result=False):
if __name__ == '__main__':
dist.spawn(train, args=(True,), nprocs=2, gpus='4,5')
"""
# NOTE(chenweihang): [ why only supports python3.4+ ? ]
# Python supported setting the child process startup method
# since 3.4. The previous version can only use the default startup
# method, while the default startup method of Unix is fork, which
# cannot support CUDA runtime multi-process
_py_supported_check()

# Give an error hint when the users enter a configuration option
# that does not exist
_options_valid_check(options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import os
import sys
import unittest

from parallel_dygraph_mnist import TestMnist
Expand Down Expand Up @@ -64,7 +63,7 @@ def test_mnist_xpu(self):

class TestParallelDygraphMnistSpawn(TestDistSpawnRunner):
def test_mnist_with_spawn(self):
if fluid.core.is_compiled_with_cuda() and sys.version_info >= (3, 4):
if fluid.core.is_compiled_with_cuda():
self.check_dist_result_with_spawn(test_class=TestMnist, delta=1e-5)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import os
import sys
import unittest

from parallel_dygraph_no_sync import TestNoSync
Expand Down Expand Up @@ -80,7 +79,7 @@ def test_no_sync_control_flow(self):

class TestParallelDygraphNoSyncSpawn(TestDistSpawnRunner):
def test_no_sync_with_spawn(self):
if fluid.core.is_compiled_with_cuda() and sys.version_info >= (3, 4):
if fluid.core.is_compiled_with_cuda():
self.check_dist_result_with_spawn(test_class=TestNoSync, delta=1e-5)


Expand All @@ -89,7 +88,7 @@ def _args_config(self, args):
args.find_unused_parameters = True

def test_no_sync_with_spawn(self):
if fluid.core.is_compiled_with_cuda() and sys.version_info >= (3, 4):
if fluid.core.is_compiled_with_cuda():
self.check_dist_result_with_spawn(
test_class=TestNoSyncUnusedParam, delta=1e-5
)
Expand All @@ -100,7 +99,7 @@ def _args_config(self, args):
args.find_unused_parameters = True

def test_no_sync_with_spawn(self):
if fluid.core.is_compiled_with_cuda() and sys.version_info >= (3, 4):
if fluid.core.is_compiled_with_cuda():
self.check_dist_result_with_spawn(
test_class=TestNoSyncControlFlow, delta=1e-5
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import os
import sys
import unittest

from parallel_dygraph_se_resnext import TestSeResNeXt
Expand Down Expand Up @@ -43,7 +42,7 @@ def test_se_resnext(self):

class TestParallelDygraphSeResNeXtSpawn(TestDistSpawnRunner):
def test_se_resnext_with_spawn(self):
if fluid.core.is_compiled_with_cuda() and sys.version_info >= (3, 4):
if fluid.core.is_compiled_with_cuda():
self.check_dist_result_with_spawn(
test_class=TestSeResNeXt, delta=0.01
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import os
import sys
import unittest

from parallel_dygraph_sparse_embedding import TestSparseEmbedding
Expand Down Expand Up @@ -61,7 +60,7 @@ def test_sparse_embedding_fp64(self):

class TestParallelDygraphSparseEmdeddingSpawn(TestDistSpawnRunner):
def test_sparse_embedding_with_spawn(self):
if fluid.core.is_compiled_with_cuda() and sys.version_info >= (3, 4):
if fluid.core.is_compiled_with_cuda():
self.check_dist_result_with_spawn(
test_class=TestSparseEmbedding, delta=1e-5
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import os
import sys
import unittest

from parallel_dygraph_sparse_embedding_over_height import (
Expand Down Expand Up @@ -47,7 +46,7 @@ def test_sparse_embedding(self):

class TestParallelDygraphSparseEmdeddingOverHeightSpawn(TestDistSpawnRunner):
def test_sparse_embedding_with_spawn(self):
if fluid.core.is_compiled_with_cuda() and sys.version_info >= (3, 4):
if fluid.core.is_compiled_with_cuda():
self.check_dist_result_with_spawn(
test_class=TestSparseEmbeddingOverHeight, delta=1e-5
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import os
import sys
import unittest

from parallel_dygraph_unused_variables import TestSparseEmbeddingUnusedVars
Expand Down Expand Up @@ -51,7 +50,7 @@ def _setup_config(self):

class TestSparseEmbeddingUnusedVarsSpawn(TestDistSpawnRunner):
def test_mnist_with_spawn(self):
if fluid.core.is_compiled_with_cuda() and sys.version_info >= (3, 4):
if fluid.core.is_compiled_with_cuda():
self.check_dist_result_with_spawn(
test_class=TestSparseEmbeddingUnusedVars, delta=1e-5
)
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/fluid/tests/unittests/test_paddle_save_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def test_pickle_protocol(self):
protocols = [
2,
]
if sys.version_info.major >= 3 and sys.version_info.minor >= 4:
protocols += [3, 4]
if sys.version_info.major >= 3 and sys.version_info.minor >= 7:
protocols += [3, 7]
for protocol in protocols:
paddle.save(save_dict, path, pickle_protocol=protocol)
dict_load = paddle.load(path)
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/fluid/tests/unittests/test_static_save_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -1801,8 +1801,8 @@ def test_pickle_protocol(self):
protocols = [
2,
]
if sys.version_info.major >= 3 and sys.version_info.minor >= 4:
protocols += [3, 4]
if sys.version_info.major >= 3 and sys.version_info.minor >= 7:
protocols += [3, 7]
for protocol in protocols:
paddle.fluid.save(prog, path, protocol)
# set var to zero
Expand Down
12 changes: 1 addition & 11 deletions python/paddle/hapi/progressbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import time
import numpy as np
import struct
from collections import namedtuple

__all__ = []

Expand Down Expand Up @@ -57,16 +56,7 @@ def __init__(
)

def _get_max_width(self):
if sys.version_info > (3, 3):
from shutil import get_terminal_size
else:
try:
from backports.shutil_get_terminal_size import get_terminal_size
except:

def get_terminal_size():
terminal_size = namedtuple("terminal_size", "columns lines")
return terminal_size(80, 24)
from shutil import get_terminal_size

terminal_width, _ = get_terminal_size()
terminal_width = terminal_width if terminal_width > 0 else 80
Expand Down
8 changes: 0 additions & 8 deletions python/paddle/incubate/multiprocessing/reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ def _supported_check():

return False

if not sys.version_info >= (3, 4):
warnings.warn(
"Use `paddle.multiprocessing` to share paddle tensor "
"requires python version greater than 3.4 ."
" `paddle.multiprocessing` will not take any effect !!!"
)
return False

return True


Expand Down
70 changes: 2 additions & 68 deletions python/paddle/utils/gast/ast3.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,7 @@ def visit_AsyncWith(self, node):
return new_node

def visit_Call(self, node):
if sys.version_info.minor < 5:
if node.starargs:
star = gast.Starred(self._visit(node.starargs), gast.Load())
gast.copy_location(star, node)
starred = [star]
else:
starred = []

if node.kwargs:
kw = gast.keyword(None, self._visit(node.kwargs))
gast.copy_location(kw, node.kwargs)
kwargs = [kw]
else:
kwargs = []
else:
starred = kwargs = []
starred = kwargs = []

new_node = gast.Call(
self._visit(node.func),
Expand Down Expand Up @@ -235,17 +220,6 @@ def visit_ExceptHandler(self, node):
else:
return self.generic_visit(node)

if sys.version_info.minor < 6:

def visit_comprehension(self, node):
new_node = gast.comprehension(
target=self._visit(node.target),
iter=self._visit(node.iter),
ifs=self._visit(node.ifs),
is_async=0,
)
return ast.copy_location(new_node, node)


class GAstToAst3(GAstToAst):
if sys.version_info.minor < 9:
Expand Down Expand Up @@ -331,47 +305,7 @@ def visit_ExceptHandler(self, node):
else:
return self.generic_visit(node)

if sys.version_info.minor < 5:

def visit_Call(self, node):
if node.args and isinstance(node.args[-1], gast.Starred):
args = node.args[:-1]
starargs = node.args[-1].value
else:
args = node.args
starargs = None

if node.keywords and node.keywords[-1].arg is None:
keywords = node.keywords[:-1]
kwargs = node.keywords[-1].value
else:
keywords = node.keywords
kwargs = None

new_node = ast.Call(
self._visit(node.func),
self._visit(args),
self._visit(keywords),
self._visit(starargs),
self._visit(kwargs),
)
ast.copy_location(new_node, node)
return new_node

def visit_ClassDef(self, node):
self.generic_visit(node)
new_node = ast.ClassDef(
name=self._visit(node.name),
bases=self._visit(node.bases),
keywords=self._visit(node.keywords),
body=self._visit(node.body),
decorator_list=self._visit(node.decorator_list),
starargs=None,
kwargs=None,
)
return ast.copy_location(new_node, node)

elif sys.version_info.minor < 8:
if sys.version_info.minor < 8:

def visit_FunctionDef(self, node):
new_node = ast.FunctionDef(
Expand Down
10 changes: 1 addition & 9 deletions python/paddle/vision/datasets/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,7 @@ def _find_classes(self, dir):
and class_to_idx is a dictionary.

"""
if sys.version_info >= (3, 5):
# Faster and available in Python 3.5 and above
classes = [d.name for d in os.scandir(dir) if d.is_dir()]
else:
classes = [
d
for d in os.listdir(dir)
if os.path.isdir(os.path.join(dir, d))
]
classes = [d.name for d in os.scandir(dir) if d.is_dir()]
classes.sort()
class_to_idx = {classes[i]: i for i in range(len(classes))}
return classes, class_to_idx
Expand Down
2 changes: 1 addition & 1 deletion tools/dockerfile/build_scripts/ssl-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

print("Testing SSL certificate checking for Python:", sys.version)

if sys.version_info[:2] < (2, 7) or sys.version_info[:2] < (3, 4):
if sys.version_info[:2] < (2, 7):
print("This version never checks SSL certs; skipping tests")
sys.exit(0)

Expand Down