提交 6d0d5e5a 编写于 作者: M Megvii Engine Team 提交者: Xu Xinran

fix(mge/redis_server): fix bug for external connection

GitOrigin-RevId: 0b595712d79a3d8df5875ede3dfebade273747ba
上级 15d1bd4d
......@@ -60,14 +60,7 @@ class PersistentCacheOnServer(_PersistentCache):
def _conn(self):
"""get redis connection"""
if self._cached_conn is None:
try:
self._cached_conn = self.make_redis_conn()
except Exception as exc:
get_logger().error(
"failed to connect to cache server: {!r}; fallback to "
"in-memory cache".format(exc)
)
self._cached_conn = _FakeRedisConn()
self._cached_conn = _FakeRedisConn()
self._prefix = self.make_user_prefix()
return self._cached_conn
......@@ -76,14 +69,6 @@ class PersistentCacheOnServer(_PersistentCache):
def make_user_prefix(cls):
return "mgbcache:{}".format(getpass.getuser())
@classmethod
def make_redis_conn(cls):
import redis
conn = redis.StrictRedis(
'localhost', 6381,
socket_connect_timeout=2, socket_timeout=1)
return conn
def _make_key(self, category, key):
prefix_with_version = "{}:MGB{}".format(self._prefix, __version__)
......@@ -103,31 +88,3 @@ class PersistentCacheOnServer(_PersistentCache):
return self._prev_get_refkeep
def _clean():
match = PersistentCacheOnServer.make_user_prefix() + "*"
conn = PersistentCacheOnServer.make_redis_conn()
cursor = 0
nr_del = 0
while True:
cursor, values = conn.scan(cursor, match)
if values:
conn.delete(*values)
nr_del += len(values)
if not cursor:
break
print("{} cache entries deleted".format(nr_del))
def main():
parser = argparse.ArgumentParser(description="manage persistent cache")
subp = parser.add_subparsers(description="action to be performed", dest="cmd")
subp.required = True
subp_clean = subp.add_parser("clean", help="clean all the cache of current user")
subp_clean.set_defaults(action=_clean)
args = parser.parse_args()
args.action()
if __name__ == "__main__":
main()
import numpy as np
import megengine as mge
from megengine.functional.debug_param import set_conv_execution_strategy
from megengine.module.conv import Conv2d
def test_fastrun():
set_conv_execution_strategy("PROFILE")
x = Conv2d(1, 1, kernel_size=1, bias=True)
a = mge.tensor(np.random.randn(1, 1, 1, 1).astype(np.float32))
a = x(a)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册